home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume7 / nethack3 / patch7e < prev    next >
Encoding:
Text File  |  1990-02-26  |  59.5 KB  |  2,298 lines

  1. Path: uunet!zephyr.ens.tek.com!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v09i005:  NetHack3 -  display oriented dungeons & dragons (Ver. 3.0), Patch7e
  5. Message-ID: <5219@tekred.CNA.TEK.COM>
  6. Date: 24 Feb 90 00:30:49 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 2287
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Izchak Miller <izchak@linc.cis.upenn.edu>
  12. Posting-number: Volume 9, Issue 5
  13. Archive-name: NetHack3/Patch7e
  14. Patch-To: NetHack3: Volume 7, Issue 56-93
  15.  
  16.  
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 5 (of 30)."
  25. # Contents:  patch7.15
  26. # Wrapped by billr@saab on Wed Feb 21 10:04:26 1990
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'patch7.15' -a "${1}" != "-c" ; then 
  29.   echo shar: Renaming existing file \"'patch7.15'\" to \"'patch7.15.orig'\"
  30.   mv -f 'patch7.15' 'patch7.15.orig'
  31. fi
  32. echo shar: Extracting \"'patch7.15'\" \(56738 characters\)
  33. sed "s/^X//" >'patch7.15' <<'END_OF_FILE'
  34. X*** /dev/null    Mon Feb 19 21:20:23 1990
  35. X--- mac/MD.rsrc.hqx    Thu Feb  8 17:43:51 1990
  36. X***************
  37. X*** 0 ****
  38. X--- 1,39 ----
  39. X+ (This file must be converted with BinHex 4.0)
  40. X+ 
  41. X+ :"de%,R*cFQ-!!!!!!!!!!!!"!!!!!!!!!!0JYHX!!!!!!3!!!!,d!!!"p!!!!'a
  42. X+ 
  43. X+ c1J!!!"3!%5T51NPZBfaeC'9c1L!!!!!!%J!4+P-k53G04#jbFh*M!J!!!!!!!!!
  44. X+ 
  45. X+ !!!!!!3!!M!"J!!!!!!Zc!!!!!!!!!!!!!!%!!)`!B!!!!)3!!!!!!!!!!!!!!!!
  46. X+ 
  47. X+ !!+(b#bi!!!!!!!!$B-`N!GJ!!!!F!f)!$%024%8!!J"U8%eMG!!'!)j%594-!!m
  48. X+ 
  49. X+ !iN&-8P3!$`'L58026J!!!Q*048j9!!)#EP088L!!"J+53dj86!!!!ZC*3diM!!%
  50. X+ 
  51. X+ #mP*05e)!!!-+4P*&4J!"!aC#6N4-!!!$,P""9%J!!!-k!!$rrb!!!!!!!-YF!!%
  52. X+ 
  53. X+ !!!!9!#J!+!$)!8!!!Irr!!!!!!!!!-J!!!!!cJ!)!!!!!!"d!$-!L!"["!*25`!
  54. X+ 
  55. X+ !!!!!G!#H!)J!fJ3'3f&ZBf9X!!!!!!!2!!m!(`"("J4NBA4K!!!!!!!3!%J!)!"
  56. X+ 
  57. X+ i"J4NBA4P!!!!!!!S!%J!1!#J"JK`CA*YEfjcG!!!!!!!%!#J!#!!k!B'FR9YEh*
  58. X+ 
  59. X+ c!!!!!!!S!!m!1!"("J9dFQ&`Fd%!!!!!!#J!S3!i!4%'$'pLDQ9MG#"ZB@ePF`!
  60. X+ 
  61. X+ !!!!!3!!3!&!!m!BGE@pZFh3JFQ9cEh9bBf8JB@jN)'CTE'8JD@0[ER02!!!!&3!
  62. X+ 
  63. X+ !!!!""!&h!!%!!!!!!!!!!2"J!!!!!1`!#J!!!!!![`%H!0%"EJ3%6h"PEJ!!!!!
  64. X+ 
  65. X+ !!!)l!&!#633'5'PNC'9Z!!!!!!$D!4m!l!&["!C$B@jMC@`!!!!!!#F"'J!k!A1
  66. X+ 
  67. X+ !!!!!!!!!4!%J!&B"F!3&4@TPBh4I!!!!!!"G!5!!E`&`"!9%FQPfCH!!!!!!!%-
  68. X+ 
  69. X+ !$!$e!4F!!!!!!!!!!`"Y!"8!R3!!!!!!!!#@!4X!P`&cJ!!!!!!!!!!#&!"P!R5
  70. X+ 
  71. X+ )!!!!!!!!!J!`!#B"4JJc8'aPBA0P)'a[Bf&dC9i`)'CTE'9H-5"H-Je[FL"`FQ9
  72. X+ 
  73. X+ cFb"$B@jMC@`JG'mJB@*[FR3Ze`!!!3!!!!,d!!!"p!!!!'`!35pd"B3!!!!F!&i
  74. X+ 
  75. X+ !!84-6dF!!3!54%P86!!"!#S!b!!!!!!!!!""e+6`B2rr!!!!k`""e03!b2rr!!!
  76. X+ 
  77. X+ !'3!!!!$`B2rr!!!""!""e,J09fKTBfJJEh"dD@pZ2d2M:
  78. X*** /dev/null    Mon Feb 19 21:20:32 1990
  79. X--- mac/MacAlert.c    Mon Feb 19 12:46:17 1990
  80. X***************
  81. X*** 0 ****
  82. X--- 1,762 ----
  83. X+ /*    SCCS Id: @(#)MacAlert.c        3.0    90/01/06
  84. X+ /*      Copyright (c) Jon Watte  1989        */ 
  85. X+ /* NetHack may be freely redistributed.  See license for details. */
  86. X+ 
  87. X+ #include "hack.h"    /* */
  88. X+ 
  89. X+ /* UseMacAlert is like UseMacAlertText, but without the text parameter.
  90. X+    This is so you can simply say "UseMacAlert(CAUTION)" or similar, if
  91. X+    you use predefined alert numbers.
  92. X+ */
  93. X+ 
  94. X+ 
  95. X+ extern WindowPtr HackWindow;
  96. X+ 
  97. X+ 
  98. X+ int
  99. X+ UseMacAlert(MAno)
  100. X+ int MAno;
  101. X+ {
  102. X+     return UseMacAlertText(MAno, 0L);
  103. X+ }
  104. X+ 
  105. X+ 
  106. X+ /* UseMacAlertText fetches a record in a resource of type MAlt, and uses
  107. X+    this as a template calling MacAlert. This is so you can have ready-
  108. X+    made resources, like ALRT templates, for your MacAlerts, which makes
  109. X+    it easier to customize the program, and to translate it. It also
  110. X+    makes for clearer code...
  111. X+    
  112. X+    If the txt argument is NULL, the text from the template is used,
  113. X+    otherwise the sypplied text is used.
  114. X+ */
  115. X+ int
  116. X+ UseMacAlertText(MAno, txt)
  117. X+ int MAno;
  118. X+ char * txt;
  119. X+ {
  120. X+     MAlrtHandle foo;
  121. X+     MAlrtPtr bar;
  122. X+     int item;
  123. X+ 
  124. X+     SetResLoad(1);
  125. X+     foo = (MAlrtHandle) GetResource(MAtype, MAno);
  126. X+     if(foo) {
  127. X+         MoveHHi(foo);
  128. X+         HLock(foo);
  129. X+         bar = *foo;
  130. X+         item = MacAlert(bar->width, bar->height, bar->PICTno,
  131. X+             txt != 0L ? txt : bar->text, bar->but1, bar->but2, bar->but3,
  132. X+             bar->but4, bar->def, bar->esc);
  133. X+     } else {
  134. X+         if(!flags.silent) SysBeep(20);
  135. X+         item = -1;
  136. X+     }
  137. X+ 
  138. X+     ReleaseResource(foo);
  139. X+     DisposHandle(foo);
  140. X+     return item;
  141. X+ }
  142. X+ 
  143. X+ 
  144. X+ /* This is the MacAlert function. It creates a new window, frames it
  145. X+    (like a modal dialog) and tries to position the various buttons,
  146. X+    text and picture in a reasonable way. The arguments are:
  147. X+    
  148. X+    width : width of the window. If less than a constant, it defaults
  149. X+            to that constant.
  150. X+    height: see width.
  151. X+    PICTno: Resource ID of a PICT to display. If 0, no PICT is displayed.
  152. X+    text  : the C string containing the relevant text to be displayed.
  153. X+    but1 -: These are the button texts. Empty strings (they point at 0)
  154. X+    - but4: makes that button go away. If all are empty, the default OK
  155. X+            button text is used.
  156. X+    def   : This is which button is default, starting button # 1.
  157. X+    esc   : This is the button that corresponds to the ESC key.
  158. X+ 
  159. X+    The function returns the button hit, or maybe -1 on error.
  160. X+ */
  161. X+ int
  162. X+ MacAlert(width, height, PICTno, text, but1, but2, but3, but4, def, esc)
  163. X+ int width, height, PICTno;
  164. X+ char * text,* but1, * but2, * but3, * but4;
  165. X+ int def, esc;
  166. X+ {
  167. X+     PicHandle thePICT;
  168. X+     char border[8];
  169. X+     EventRecord theEvent;
  170. X+     GrafPtr savedPort;
  171. X+     WindowPtr theWindow, tmpWind;
  172. X+     Rect bounds, textBox, brect[4];
  173. X+     char hilite[4], * but[4], s1[2], s2[2];
  174. X+     int nobutts, x, pool, spacing, heig, bwid[4],
  175. X+         item, c, ret;
  176. X+     long finalTicks;
  177. X+ 
  178. X+     memset(hilite, sizeof(hilite), 0);
  179. X+     memset(bwid, sizeof(bwid), 0);
  180. X+     SetCursor(&arrow);
  181. X+     def--;
  182. X+     esc--;
  183. X+     GetPort(&savedPort);
  184. X+ 
  185. X+     if(PICTno)
  186. X+         thePICT = (PicHandle) GetResource('PICT', PICTno);
  187. X+     else
  188. X+         thePICT = 0;
  189. X+     if(thePICT) DetachResource(thePICT);
  190. X+     bounds = (MAINGRAFPORT)->portRect;
  191. X+ 
  192. X+     but[0] = but1;
  193. X+     but[1] = but2;
  194. X+     but[2] = but3;
  195. X+     but[3] = but4;
  196. X+ 
  197. X+     if(width > bounds.right) width = bounds.right;
  198. X+     if(width < MIN_WIDTH) width = MIN_WIDTH;
  199. X+     if(height > bounds.bottom) height = bounds.bottom;
  200. X+     if(height < MIN_HEIGHT) height = MIN_HEIGHT;
  201. X+ 
  202. X+     InsetRect(&bounds, (int) ((bounds.right - width) >> 1), (int)
  203. X+         ((bounds.bottom - height) >> 1));
  204. X+     theWindow = NewWindow(0L, &bounds, "", 1, plainDBox, 0L, 0, 0L);
  205. X+     ShowWindow(theWindow);
  206. X+     SelectWindow(theWindow);
  207. X+     SetPort(theWindow);
  208. X+     OffsetRect(&bounds, - bounds.left, - bounds.top);
  209. X+ 
  210. X+     nobutts = 0;
  211. X+     if(but1[0]) nobutts=1;
  212. X+     if(but2[0]) nobutts=2;
  213. X+     if(but3[0]) nobutts=3;
  214. X+     if(but4[0]) nobutts=4;
  215. X+ 
  216. X+     if(!nobutts) {
  217. X+         but[0] = "OK";
  218. X+         nobutts++;
  219. X+     }
  220. X+ 
  221. X+     spacing = 0;
  222. X+     for(x=0 ; x < nobutts; x++) {
  223. X+         bwid[x] = TextWidth(but[x], 0, strlen(but[x])) + 2 * BUT_MARGIN;
  224. X+         spacing += bwid[x] + BUT_SPACING;
  225. X+     }
  226. X+ 
  227. X+     pool = bounds.right - 2 * BUT_MARGIN;
  228. X+ 
  229. X+     heig = 1;
  230. X+     while(spacing / heig > pool - (nobutts - 1) * BUT_SPACING) {
  231. X+         heig++;
  232. X+     }
  233. X+ 
  234. X+     for(x=0; x<nobutts; x++) {
  235. X+         bwid[x] = (int) ((float) bwid[x] / spacing * pool);
  236. X+     }
  237. X+ 
  238. X+     pool = BUT_MARGIN + BUT_SPACING;
  239. X+     heig = bounds.bottom - BUT_MARGIN - BUT_SPACING - BUT_HEIGHT * heig;
  240. X+     for(x=0; x<nobutts; x++) {
  241. X+         SetRect(&(brect[x]), pool, heig, pool + bwid[x], bounds.bottom -
  242. X+             BUT_SPACING - BUT_MARGIN);
  243. X+         pool += bwid[x] + BUT_SPACING;
  244. X+         hilite[x] = 0;
  245. X+     }
  246. X+ 
  247. X+     InsetRect(&bounds, 2, 2);
  248. X+     textBox = bounds;
  249. X+     if(thePICT) {
  250. X+         textBox.left += (*thePICT)->picFrame.right;
  251. X+     }
  252. X+     textBox.left += 8;
  253. X+     textBox.right -= 8;
  254. X+     textBox.top += 8;
  255. X+     textBox.bottom = heig - BUT_MARGIN;
  256. X+     if(textBox.bottom < textBox.top + 15) {
  257. X+         textBox.bottom = bounds.bottom - 8;
  258. X+     }
  259. X+ 
  260. X+     goto mainLoop;
  261. X+ 
  262. X+ drawWindow:
  263. X+     SetPort(theWindow);
  264. X+     EraseRect(&(theWindow->portRect));
  265. X+     PenNormal();
  266. X+     PenSize(BORDER_WIDTH, BORDER_WIDTH);
  267. X+     GetIndPattern((void *) border, 0, BORDER_PAT);
  268. X+     PenPat(border);
  269. X+     FrameRect(&bounds);
  270. X+ 
  271. X+     PenNormal();
  272. X+ 
  273. X+     if(thePICT) {
  274. X+         HLock(thePICT);
  275. X+         DrawPicture(thePICT, &((*thePICT)->picFrame));
  276. X+         HUnlock(thePICT);
  277. X+     }
  278. X+ 
  279. X+     PenNormal();
  280. X+     TextFont(0);
  281. X+     TextSize(12);
  282. X+     TextBox(text, strlen(text), &textBox, teJustLeft);
  283. X+ 
  284. X+     for(x=0; x<nobutts; x++) {
  285. X+         EraseRoundRect(&(brect[x]), BUT_CORNER, BUT_CORNER);
  286. X+         FrameRoundRect(&(brect[x]), BUT_CORNER, BUT_CORNER);
  287. X+         InsetRect(&(brect[x]), BUT_MARGIN, 3);
  288. X+         TextBox(but[x], strlen(but[x]), &(brect[x]), teJustCenter);
  289. X+         InsetRect(&(brect[x]), - BUT_MARGIN, - 3);
  290. X+         if(hilite[x]) {
  291. X+             InvertRoundRect(&(brect[x]), BUT_CORNER, BUT_CORNER);
  292. X+         }
  293. X+         if(x == def) {
  294. X+             PenSize(FRAME_WIDTH, FRAME_WIDTH);
  295. X+             InsetRect(&(brect[x]), - FRAME_WIDTH - FRAME_OFFSET,
  296. X+                 - FRAME_WIDTH - FRAME_OFFSET);
  297. X+             FrameRoundRect(&(brect[x]), FRAME_CORNER, FRAME_CORNER);
  298. X+             InsetRect(&(brect[x]), FRAME_WIDTH + FRAME_OFFSET,
  299. X+                 FRAME_WIDTH + FRAME_OFFSET);
  300. X+             PenNormal();
  301. X+         }
  302. X+     }
  303. X+ 
  304. X+ mainLoop:
  305. X+     while(1) {
  306. X+         if(WaitNextEvent(-1, &theEvent, 0L, 0L)) {
  307. X+             switch(theEvent.what) {
  308. X+ 
  309. X+             case updateEvt :
  310. X+                 BeginUpdate((WindowPtr) theEvent.message);
  311. X+                 EndUpdate((WindowPtr) theEvent.message);
  312. X+                 goto drawWindow;
  313. X+ 
  314. X+             case mouseDown :
  315. X+                 if (FindWindow(theEvent.where, &tmpWind) < inContent ||
  316. X+                     tmpWind != theWindow) {
  317. X+                     if(!flags.silent) SysBeep(20);
  318. X+                     item = -1;
  319. X+                 } else {
  320. X+                     item = TrackThem(brect, hilite, nobutts);
  321. X+                 }
  322. X+                 if(item >= 0) {
  323. X+                     Delay(FLASH_TIME, &finalTicks);
  324. X+                     InvertRoundRect(&(brect[item]), BUT_CORNER, BUT_CORNER);
  325. X+                     ret = item + 1;
  326. X+                     goto getout;
  327. X+                 }
  328. X+                 break;
  329. X+ 
  330. X+             case keyDown :
  331. X+                 c = theEvent.message & 0xFF;
  332. X+                 if((c == 13) || (c == 3)) {
  333. X+                     if(def >= 0) {
  334. X+                         InvertRoundRect(&(brect[def]), BUT_CORNER, BUT_CORNER);
  335. X+                         Delay(FLASH_TIME, &finalTicks);
  336. X+                         InvertRoundRect(&(brect[def]), BUT_CORNER, BUT_CORNER);
  337. X+                         ret = def + 1;
  338. X+                         goto getout;
  339. X+                     }
  340. X+                 }
  341. X+                 if(c == 27) {
  342. X+                     if(esc >= 0) {
  343. X+                         InvertRoundRect(&(brect[esc]), BUT_CORNER, BUT_CORNER);
  344. X+                         Delay(FLASH_TIME, &finalTicks);
  345. X+                         InvertRoundRect(&(brect[esc]), BUT_CORNER, BUT_CORNER);
  346. X+                         ret = esc + 1;
  347. X+                         goto getout;
  348. X+                     }
  349. X+                 }
  350. X+                 for(x=0; x<nobutts; x++) {
  351. X+                     s1[0] = 1;
  352. X+                     s1[1] = c;
  353. X+                     s2[0] = 1;
  354. X+                     s2[1] = but[x][0];
  355. X+                     UprString(s1, 1);
  356. X+                     UprString(s2, 1);
  357. X+                     if(s1[1] == s2[1]) {
  358. X+                         InvertRoundRect(&(brect[x]), BUT_CORNER, BUT_CORNER);
  359. X+                         Delay(FLASH_TIME, &finalTicks);
  360. X+                         InvertRoundRect(&(brect[x]), BUT_CORNER, BUT_CORNER);
  361. X+                         ret = x + 1;
  362. X+                         goto getout;
  363. X+                     }
  364. X+                 }
  365. X+ 
  366. X+                 PenSize(FRAME_WIDTH, FRAME_WIDTH);
  367. X+                 InsetRect(&(brect[def]), - FRAME_WIDTH - FRAME_OFFSET,
  368. X+                     - FRAME_WIDTH - FRAME_OFFSET);
  369. X+                 PenMode(patXor);
  370. X+                 FrameRoundRect(&(brect[def]), FRAME_CORNER, FRAME_CORNER);
  371. X+                 InsetRect(&(brect[def]), FRAME_WIDTH + FRAME_OFFSET,
  372. X+                     FRAME_WIDTH + FRAME_OFFSET);
  373. X+                 PenNormal();
  374. X+ 
  375. X+                 def++;
  376. X+                 def %= nobutts;
  377. X+ 
  378. X+                 PenSize(FRAME_WIDTH, FRAME_WIDTH);
  379. X+                 InsetRect(&(brect[def]), - FRAME_WIDTH - FRAME_OFFSET,
  380. X+                     - FRAME_WIDTH - FRAME_OFFSET);
  381. X+                 FrameRoundRect(&(brect[def]), FRAME_CORNER, FRAME_CORNER);
  382. X+                 InsetRect(&(brect[def]), FRAME_WIDTH + FRAME_OFFSET,
  383. X+                     FRAME_WIDTH + FRAME_OFFSET);
  384. X+                 PenNormal();
  385. X+ 
  386. X+                 break;
  387. X+ 
  388. X+             default:
  389. X+                 ;
  390. X+             }
  391. X+         }
  392. X+     }
  393. X+ 
  394. X+ getout:
  395. X+     DisposeWindow(theWindow);
  396. X+     if(thePICT) DisposHandle(thePICT);
  397. X+     SetPort(savedPort);
  398. X+     bounds = savedPort->portRect;
  399. X+     InvalRect(&bounds);
  400. X+ 
  401. X+     return ret;
  402. X+ }
  403. X+ 
  404. X+ 
  405. X+ /* TrackThem is a help function to MacAlert, it tracks buttons,
  406. X+    returns the button number (0 - (no_butts-1)) or -1 if no button
  407. X+    was hit. */
  408. X+ int
  409. X+ TrackThem(b_rect, hi_lite, no_butts)
  410. X+ Rect * b_rect;
  411. X+ char * hi_lite;
  412. X+ int no_butts;
  413. X+ {
  414. X+ Point p;
  415. X+ int x, i;
  416. X+ 
  417. X+     while(Button()) {
  418. X+         SystemTask();
  419. X+         GetMouse(&p);
  420. X+         for(x=0; x<no_butts; x++) {
  421. X+             if(PtInRect(p, &(b_rect[x]))) {
  422. X+                 if(!hi_lite[x]) {
  423. X+                     hi_lite[x] = 1;
  424. X+                     InvertRoundRect(&(b_rect[x]), BUT_CORNER, BUT_CORNER);
  425. X+                 }
  426. X+             } else {
  427. X+                 if(hi_lite[x]) {
  428. X+                     hi_lite[x] = 0;
  429. X+                     InvertRoundRect(&(b_rect[x]), BUT_CORNER, BUT_CORNER);
  430. X+                 }
  431. X+             }
  432. X+         }
  433. X+     }
  434. X+ 
  435. X+     i = -1;
  436. X+     for(x=0; x<no_butts; x++) {
  437. X+         if(hi_lite[x]) i=x;
  438. X+     }
  439. X+ 
  440. X+     return i;
  441. X+ }
  442. X+ 
  443. X+ 
  444. X+ /* #defines for the mini-pager */
  445. X+ 
  446. X+ #define QUIT_BUT 0
  447. X+ #define TOP_BUT 1
  448. X+ #define MORE_BUT 2
  449. X+ #define MORE_TEXT    20
  450. X+ #define LITTLE_MORE_TEXT 20
  451. X+ #define TOP_TEXT    -2
  452. X+ #define QUIT_PAGER    -1
  453. X+ #define NULL_EVT    -3
  454. X+ 
  455. X+ 
  456. X+ static Rect rectSave;
  457. X+ static int window_inited = 0;
  458. X+ 
  459. X+ int more_disabled;
  460. X+ 
  461. X+ 
  462. X+ void
  463. X+ draw_box(char * whence, size_t length, Rect * where, int strip)
  464. X+ {
  465. X+ Point mark;
  466. X+ size_t bar = 0;
  467. X+ GrafPtr aPort;
  468. X+ 
  469. X+     TextFont(4);
  470. X+     TextSize(9);
  471. X+     GetPort(&aPort);
  472. X+     ClipRect(where);
  473. X+ 
  474. X+     mark.h = where->left + 3;
  475. X+     mark.v = where->top + 11;
  476. X+ 
  477. X+     while(length-- && mark.v < where->bottom) {
  478. X+         MoveTo(mark.h, mark.v);
  479. X+ 
  480. X+         switch(whence[bar]) {
  481. X+ 
  482. X+         case 0x9:
  483. X+             mark.h += 45;
  484. X+             mark.h -= mark.h % 48;
  485. X+             mark.h += 3;
  486. X+             break;
  487. X+ 
  488. X+         case 0x7:
  489. X+             if(!flags.silent) {
  490. X+                 if(!flags.silent) SysBeep(20);
  491. X+             }
  492. X+             break;
  493. X+ 
  494. X+         case 0xC:
  495. X+             EraseRect(where);
  496. X+             mark.h = where->left + 3;
  497. X+             mark.v = where->top + 11;
  498. X+             break;
  499. X+ 
  500. X+         case 0xA:
  501. X+         case 0xD:
  502. X+             if(strip) bar++;
  503. X+             mark.h = where->left + 3;
  504. X+             mark.v += 11;
  505. X+             MoveTo(mark.h, mark.v);
  506. X+             break;
  507. X+ 
  508. X+         default:
  509. X+             if(PtInRect(mark, where))
  510. X+                 DrawChar(whence[bar]);
  511. X+             mark.h += 6;
  512. X+             break;
  513. X+         }
  514. X+         bar++;
  515. X+     }
  516. X+     ClipRect(&(aPort->portRect));
  517. X+ }
  518. X+ 
  519. X+ 
  520. X+ void
  521. X+ draw_btns(Rect * buttons)
  522. X+ {
  523. X+ int i;
  524. X+ 
  525. X+     PenNormal();
  526. X+ 
  527. X+     TextFont(0);    /* System Font: usually Chicago */
  528. X+     TextSize(12);    /* 12 pt */
  529. X+     for(i=0; i<3; i++) {
  530. X+         EraseRect(&(buttons[i]));
  531. X+         FrameRoundRect(&(buttons[i]), BUT_CORNER, BUT_CORNER);
  532. X+         MoveTo(buttons[i].left + 5, buttons[i].top + 13);
  533. X+         DrawText("Quit TopMore", i * 4, 4);
  534. X+     }
  535. X+     if(more_disabled) {
  536. X+         PenPat(patBic);
  537. X+         PenPat(gray);
  538. X+         PaintRoundRect(&(buttons[MORE_BUT]), BUT_CORNER, BUT_CORNER);
  539. X+         PenNormal();
  540. X+     }
  541. X+ }
  542. X+ 
  543. X+ 
  544. X+ static char lite[3] = { 0, 0, 0, };
  545. X+ 
  546. X+ 
  547. X+ int
  548. X+ how_scroll(Rect * btns, GrafPtr port)
  549. X+ {
  550. X+ EventRecord theEvent;
  551. X+ int hit;
  552. X+ long finalTicks;
  553. X+ 
  554. X+     while(!WaitNextEvent(everyEvent, &theEvent, 0L, 0L));
  555. X+     SetPort(port);
  556. X+     ClipRect(&(port->portRect));
  557. X+ 
  558. X+     switch(theEvent.what) {
  559. X+ 
  560. X+     case keyDown:
  561. X+         switch(theEvent.message & 0xFF) {
  562. X+ 
  563. X+         case 0x20:
  564. X+         case 'M':
  565. X+         case 'm':
  566. X+             if(!more_disabled) {
  567. X+                 InvertRoundRect(&(btns[MORE_BUT]), BUT_CORNER, BUT_CORNER);
  568. X+                 lite[MORE_BUT] = 1;
  569. X+                 return MORE_TEXT;
  570. X+             } else if(!flags.silent) SysBeep(20);
  571. X+             break;
  572. X+ 
  573. X+         case 0xD:
  574. X+         case 0xA:
  575. X+             if(!more_disabled) {
  576. X+                 InvertRoundRect(&(btns[MORE_BUT]), BUT_CORNER, BUT_CORNER);
  577. X+                 lite[MORE_BUT] = 1;
  578. X+                 return LITTLE_MORE_TEXT;
  579. X+             } else if(!flags.silent) SysBeep(20);
  580. X+             break;
  581. X+ 
  582. X+         case 'Q':
  583. X+         case 'q':
  584. X+         case 0x3:
  585. X+         case 0x1B:
  586. X+             InvertRoundRect(&(btns[QUIT_BUT]), BUT_CORNER, BUT_CORNER);
  587. X+             return QUIT_PAGER;
  588. X+ 
  589. X+         case '.':        
  590. X+             if(theEvent.modifiers & cmdKey) {
  591. X+                 InvertRoundRect(&(btns[QUIT_BUT]), BUT_CORNER, BUT_CORNER);
  592. X+                 return QUIT_PAGER;
  593. X+             }
  594. X+             break;
  595. X+ 
  596. X+         case 't':
  597. X+         case 'T':
  598. X+             InvertRoundRect(&(btns[TOP_BUT]), BUT_CORNER, BUT_CORNER);
  599. X+             return TOP_TEXT;
  600. X+ 
  601. X+         default:
  602. X+             if(!flags.silent) SysBeep(20);
  603. X+         }
  604. X+         break;
  605. X+     case mouseDown:
  606. X+         {
  607. X+         WindowPtr xW;
  608. X+         short part = FindWindow(theEvent.where, &xW);
  609. X+             if(StripAddress(xW) != StripAddress(port)) {
  610. X+                 if(part == inDrag && theEvent.modifiers & cmdKey) {
  611. X+                 RgnHandle grayReg = GetGrayRgn();
  612. X+                 char hState = HGetState(grayReg);
  613. X+                     HLock(grayReg);
  614. X+                     DragWindow(xW, theEvent.where, &((*grayReg)->rgnBBox));
  615. X+                     HSetState(grayReg, hState);
  616. X+                 } else if(!flags.silent) SysBeep(20);
  617. X+             } else {
  618. X+                 switch(part) {
  619. X+     
  620. X+                 case inDrag:
  621. X+                     {
  622. X+                     RgnHandle grayReg = GetGrayRgn();
  623. X+                     char hState = HGetState(grayReg);
  624. X+                         HLock(grayReg);
  625. X+                         DragWindow(xW, theEvent.where, &((*grayReg)->rgnBBox));
  626. X+                         HSetState(grayReg, hState);
  627. X+                         rectSave = xW->portRect;
  628. X+                         LocalToGlobal((Point *) &(rectSave.top));
  629. X+                         LocalToGlobal((Point *) &(rectSave.bottom));
  630. X+                     }
  631. X+                     break;
  632. X+     
  633. X+                 case inContent:
  634. X+                     hit = TrackThem(btns, lite, more_disabled ? 2 : 3);
  635. X+                     switch(hit) {
  636. X+     
  637. X+                     case QUIT_BUT:
  638. X+                         return QUIT_PAGER;
  639. X+     
  640. X+                     case TOP_BUT:
  641. X+                         return TOP_TEXT;
  642. X+     
  643. X+                     case MORE_BUT:
  644. X+                         return MORE_TEXT;
  645. X+     
  646. X+                     default:
  647. X+                         if(!flags.silent) SysBeep(20);
  648. X+                     }
  649. X+                     break;
  650. X+     
  651. X+                 case inGoAway:
  652. X+                     if(TrackGoAway (xW, theEvent.where)) return QUIT_PAGER;
  653. X+                     break;
  654. X+ 
  655. X+                 default:
  656. X+                     if(!flags.silent) SysBeep(20);
  657. X+                     break;
  658. X+     
  659. X+                 }
  660. X+             }
  661. X+         }
  662. X+         break;
  663. X+ 
  664. X+     case updateEvt:
  665. X+         BeginUpdate((WindowPtr) theEvent.message);
  666. X+         if(StripAddress(theEvent.message) ==
  667. X+             StripAddress(FrontWindow())) {
  668. X+             EndUpdate((WindowPtr) theEvent.message);
  669. X+             return 0;
  670. X+         } else if(StripAddress(HackWindow) ==
  671. X+             StripAddress(theEvent.message)) {
  672. X+             SetPort(HackWindow);
  673. X+             docrt();
  674. X+             SetPort(port);
  675. X+         }
  676. X+         EndUpdate((WindowPtr) theEvent.message);
  677. X+         break;
  678. X+ 
  679. X+     default:
  680. X+         break;
  681. X+     }
  682. X+     return NULL_EVT;
  683. X+ }
  684. X+ 
  685. X+ 
  686. X+ void
  687. X+ display_data(char * buffer, size_t length, int strip, WindowPtr window)
  688. X+ {
  689. X+ Rect buttons[3], text_area, bounds;
  690. X+ size_t b_index = 0;
  691. X+ short pgEvent, bar, i;
  692. X+ 
  693. X+     more_disabled = 0;
  694. X+     text_area = window->portRect;
  695. X+     OffsetRect(&text_area, text_area.left, text_area.top);
  696. X+     InsetRect(&text_area, 3, 3);
  697. X+     bounds = text_area;
  698. X+     text_area.bottom -= 30;
  699. X+ 
  700. X+     PenNormal();
  701. X+ 
  702. X+     buttons[QUIT_BUT].left = bounds.left;
  703. X+     buttons[QUIT_BUT].top = bounds.bottom - 18;
  704. X+     buttons[QUIT_BUT].right = bounds.left + 39;
  705. X+     buttons[QUIT_BUT].bottom = bounds.bottom;
  706. X+ 
  707. X+     i = bounds.right;
  708. X+ 
  709. X+     buttons[MORE_BUT].left = i - 45;
  710. X+     buttons[MORE_BUT].top = bounds.bottom - 18;
  711. X+     buttons[MORE_BUT].right = i;
  712. X+     buttons[MORE_BUT].bottom = bounds.bottom;
  713. X+ 
  714. X+     buttons[TOP_BUT].left = i - 90;
  715. X+     buttons[TOP_BUT].top = bounds.bottom - 18;
  716. X+     buttons[TOP_BUT].right = i - 50;
  717. X+     buttons[TOP_BUT].bottom = bounds.bottom;
  718. X+ 
  719. X+     do {
  720. X+         bar = 0;
  721. X+         pgEvent = how_scroll(buttons, window);
  722. X+         if(pgEvent > 0) bar = MORE_BUT;
  723. X+         if(pgEvent == TOP_TEXT) {
  724. X+             EraseRect(&text_area);
  725. X+             more_disabled = 0;
  726. X+             b_index = 0;
  727. X+             bar = TOP_BUT;
  728. X+             pgEvent = 0;
  729. X+         }
  730. X+         if(pgEvent == 0) {
  731. X+             draw_btns(buttons);
  732. X+             lite[TOP_BUT] = 0;
  733. X+         }
  734. X+         if(pgEvent == NULL_EVT) {
  735. X+             pgEvent = 0;
  736. X+         } else {
  737. X+         int f = 0;
  738. X+             if(pgEvent > 0) f = 1;
  739. X+             while(pgEvent > 0 && b_index < length) {
  740. X+                 while(buffer[b_index] != '\r' && b_index < length) b_index++;
  741. X+                 if(buffer[b_index++] == '\r') pgEvent--;
  742. X+                 else break;
  743. X+             }
  744. X+             if(!pgEvent) {
  745. X+                 if(f) EraseRect(&text_area);
  746. X+                 draw_box(&(buffer[b_index]), length - b_index, &text_area, strip);
  747. X+             } else if(pgEvent > 0) {
  748. X+                 PenMode(patOr);
  749. X+                 PenPat(gray);
  750. X+                 PaintRoundRect(&(buttons[MORE_BUT]), BUT_CORNER,
  751. X+                     BUT_CORNER);
  752. X+                 more_disabled = 1;
  753. X+                 PenNormal();
  754. X+             }
  755. X+             if(lite[bar])
  756. X+                 InvertRoundRect(&(buttons[bar]), BUT_CORNER, BUT_CORNER);
  757. X+         }
  758. X+         for(i=0; i<3; i++) lite[i] = 0;
  759. X+ 
  760. X+     } while (pgEvent >= 0);
  761. X+ }
  762. X+ 
  763. X+ 
  764. X+ int
  765. X+ mac_more(FILE * fp, int strip)
  766. X+ {
  767. X+ size_t where, length, b_index;
  768. X+ char ** buffer, c;
  769. X+ WindowRecord pageWindow;
  770. X+ WindowPtr oldWindow;
  771. X+ GrafPtr oldPort;
  772. X+ extern WindowPtr HackWindow;
  773. X+ 
  774. X+     GetPort(&oldPort);
  775. X+     oldWindow = FrontWindow();
  776. X+     InitCursor();
  777. X+ 
  778. X+     SelectWindow(HackWindow);
  779. X+     SetPort(HackWindow);
  780. X+     EraseRect(&(HackWindow->portRect));
  781. X+     docrt();
  782. X+     ValidRect(&(HackWindow->portRect));
  783. X+         
  784. X+     where = ftell(fp);
  785. X+     fseek(fp, 0, SEEK_END);
  786. X+     length = ftell(fp);
  787. X+     fseek(fp, where, SEEK_SET);
  788. X+ 
  789. X+     if(length - where < 1)
  790. X+         return -1;
  791. X+     if((buffer = (char **) NewHandle(length)) == NULL)
  792. X+         return -1;
  793. X+     if(MemError()) {
  794. X+         DisposHandle(buffer);
  795. X+         return -1;
  796. X+     }
  797. X+ 
  798. X+     MoveHHi(buffer);
  799. X+     HLock(buffer);
  800. X+ 
  801. X+     fread(*buffer, sizeof(char), length - where, fp);
  802. X+     c = (*buffer)[length - where - 1];
  803. X+     if(!(c == 0xD || c == 0xA || c == 0)) {
  804. X+         (*buffer)[length - where - 1] = 0;
  805. X+     }
  806. X+ 
  807. X+     while(where < length) {
  808. X+         c = (*buffer)[where];
  809. X+         if(c == '\n' || c == 0xC || c == 0)
  810. X+             c =(*buffer)[where] = '\r';
  811. X+         where++;
  812. X+     }
  813. X+ 
  814. X+     if(!window_inited) {
  815. X+         rectSave = thePort->portRect;
  816. X+         rectSave.left = rectSave.right - 490;
  817. X+         rectSave.top = rectSave.bottom - 270;
  818. X+         OffsetRect(&rectSave, 10 - (rectSave.left >> 1), 40 - (rectSave.top >> 1));
  819. X+         window_inited = 1;
  820. X+     }
  821. X+ 
  822. X+     (void) NewWindow(&pageWindow, &rectSave, "\011Hack-Info", TRUE, documentProc,
  823. X+         0L, TRUE, 0L);
  824. X+     SelectWindow(&pageWindow);
  825. X+     SetPort(&pageWindow);
  826. X+     ClipRect(&(pageWindow.port.portRect));
  827. X+ 
  828. X+     display_data(*buffer, length, strip, (WindowPtr) &pageWindow);
  829. X+     HUnlock(buffer);
  830. X+     DisposHandle(buffer);
  831. X+ 
  832. X+     Delay(FLASH_TIME, &where);
  833. X+     CloseWindow(&pageWindow);
  834. X+     SelectWindow(oldWindow);
  835. X+     SetPort(oldWindow);
  836. X+     if(StripAddress(oldWindow) == StripAddress(HackWindow)) {
  837. X+         EraseRect(&(oldWindow->portRect));
  838. X+         ValidRect(&(oldWindow->portRect));
  839. X+         docrt();
  840. X+     }
  841. X+     SetPort(oldPort);
  842. X+     return 0;
  843. X+ }
  844. X+ 
  845. X*** mac/Old/mac.c    Mon Feb 19 21:22:25 1990
  846. X--- mac/mac.c    Mon Feb 19 13:40:22 1990
  847. X***************
  848. X*** 11,16 ****
  849. X--- 11,24 ----
  850. X  WindowPtr    HackWindow;    /* points to Hack's window */
  851. X  extern char    *keys[8];
  852. X  extern short macflags;
  853. X+ short cursorPos=0;
  854. X+ short repDelay;
  855. X+ long lastMD;
  856. X+ struct line {
  857. X+     struct line *next_line;
  858. X+     char *line_text;
  859. X+ } *mactexthead;
  860. X+ short maclinect, macmaxlen;
  861. X  
  862. X  int
  863. X  tgetch()
  864. X***************
  865. X*** 18,27 ****
  866. X  {
  867. X      char    ch;
  868. X      EventRecord    theEvent;
  869. X!     Rect cursorRect;
  870. X      long    message,cursorTime,start;
  871. X      MenuHandle    theMenu;
  872. X!     short    keyCode;
  873. X      term_info    *t;
  874. X      boolean    noControlKey;
  875. X      GrafPtr    oldPort,oldPort1;
  876. X--- 26,36 ----
  877. X  {
  878. X      char    ch;
  879. X      EventRecord    theEvent;
  880. X!     Rect cursorRect,box,windowRect;
  881. X      long    message,cursorTime,start;
  882. X      MenuHandle    theMenu;
  883. X!     register short    keyCode;
  884. X!     short    temp;
  885. X      term_info    *t;
  886. X      boolean    noControlKey;
  887. X      GrafPtr    oldPort,oldPort1;
  888. X***************
  889. X*** 28,46 ****
  890. X      static char nextCommand;
  891. X      short aboutBox();
  892. X      char mButtonDown();
  893. X  #define noEscapeKey    noControlKey
  894. X  #define    clearKey    0x47
  895. X  #define ESCAPEkey    0x1B
  896. X      
  897. X      t = (term_info *)GetWRefCon(HackWindow);
  898. X      cursorRect.left = t->tcur_x * t->charWidth + Screen_Border;
  899. X      cursorRect.right = cursorRect.left + t->charWidth - 1;
  900. X      cursorRect.top = t->height * t->tcur_y + Screen_Border;
  901. X      cursorRect.bottom = cursorRect.top + t->height;
  902. X!     cursorTime = GetCaretTime()/2;
  903. X!     keyCode = 0;
  904. X      noControlKey = (t->system.keyBoardType <= envMacPlusKbd) ? TRUE : FALSE;
  905. X!     
  906. X      /* permit use of cursor keys and numeric keypad */
  907. X      /* does the same translation as in msdos.c but includes cursor keys */
  908. X      ch = '\0';
  909. X--- 37,62 ----
  910. X      static char nextCommand;
  911. X      short aboutBox();
  912. X      char mButtonDown();
  913. X+     Point    mouseLoc;
  914. X+     WindowPtr    theWindow;
  915. X+     void    doUpdate();
  916. X  #define noEscapeKey    noControlKey
  917. X  #define    clearKey    0x47
  918. X  #define ESCAPEkey    0x1B
  919. X      
  920. X      t = (term_info *)GetWRefCon(HackWindow);
  921. X+     mouseLoc.h = (macflags & fMoveWRTMouse) ? t->tcur_x : (u.ux-1);
  922. X+     mouseLoc.v = (macflags & fMoveWRTMouse) ? t->tcur_y : (u.uy+1);
  923. X      cursorRect.left = t->tcur_x * t->charWidth + Screen_Border;
  924. X      cursorRect.right = cursorRect.left + t->charWidth - 1;
  925. X      cursorRect.top = t->height * t->tcur_y + Screen_Border;
  926. X      cursorRect.bottom = cursorRect.top + t->height;
  927. X!     cursorTime = GetCaretTime();
  928. X      noControlKey = (t->system.keyBoardType <= envMacPlusKbd) ? TRUE : FALSE;
  929. X!     box.left = mouseLoc.h * t->charWidth + Screen_Border;
  930. X!     box.right = box.left + t->charWidth;
  931. X!     box.top = mouseLoc.v * t->height + Screen_Border + t->height/2 - (t->charWidth/2);
  932. X!     box.bottom = box.top + t->charWidth;
  933. X      /* permit use of cursor keys and numeric keypad */
  934. X      /* does the same translation as in msdos.c but includes cursor keys */
  935. X      ch = '\0';
  936. X***************
  937. X*** 61,225 ****
  938. X      }
  939. X      GetPort(&oldPort);
  940. X      SetPort(HackWindow);
  941. X!     while (!ch) {
  942. X!         keyCode = 0;
  943. X!         GetPort(&oldPort1);
  944. X!         SetPort((GrafPtr)HackWindow);
  945. X!         /* do cursor blinking */
  946. X!         message = TickCount() + cursorTime;
  947. X!         while (!WaitNextEvent(everyEvent, &theEvent, 10L, 0L)) {
  948. X!         /* wait until something occurs */
  949. X!         if (!Invisible) {
  950. X!             if (TickCount() > message) {
  951. X!             InvertRect(&cursorRect);
  952. X!             message = TickCount() + cursorTime;
  953. X!             keyCode = !keyCode;
  954. X!             }
  955. X!         }
  956. X!         }
  957. X!         if (keyCode)
  958. X          InvertRect(&cursorRect);
  959. X!         SetPort(oldPort1);
  960. X!         if (theEvent.what == keyDown || theEvent.what == autoKey) {
  961. X!         /* use raw key codes */
  962. X!         keyCode = (LoWord(theEvent.message) & keyCodeMask)>>8;
  963. X!         if (keyCode == 50 && noEscapeKey)
  964. X!             ch = (char)ESCAPEkey;    /* ESC */
  965. X!         else if (keyCode == clearKey) {
  966. X!             macflags = macflags ^ fToggleNumPad;
  967. X!             SetWTitle(HackWindow,
  968. X!                 (macflags & fToggleNumPad)    ? "\015NetHack [MOV]"
  969. X!                             : "\015NetHack [NUM]");
  970. X!         } else if ((macflags & fToggleNumPad) &&
  971. X!                 (keyCode>64 && keyCode<127))
  972. X!             ch = t->keyMap[keyCode-65];
  973. X!         /* make the command key = control key on old Mac keyboards */
  974. X!         if ((theEvent.modifiers & cmdKey) && noControlKey) {
  975. X!             ch = (char)(theEvent.message & 0x1F);
  976. X!         }
  977. X!         if ((theEvent.modifiers & shiftKey) && (ch)) {
  978. X!             ch = (ch == '.') ? ':' : (char)toupper(ch);
  979. X!         }
  980. X!         if (theEvent.modifiers & optionKey) {
  981. X!             for(start = 43; start < 56; start++) {
  982. X!             if (t->keyMap[start] == (char)(theEvent.message & 0xFFL)) {
  983. X!                 ch = t->keyMap[start - 13];
  984. X!                 break;
  985. X!             }
  986. X!             }
  987. X!         }
  988. X!         /* not a cursor key or from the numeric keypad */
  989. X!         if (!ch && keyCode != clearKey) {
  990. X!             ch = (char)(theEvent.message & 0xFF);
  991. X!         }
  992. X!         } else {
  993. X          /* what other events to handle */
  994. X!         switch (theEvent.what) {        
  995. X!             case nullEvent:
  996. X!             SetCursor(&ARROW_CURSOR);
  997. X!             break;
  998. X!             case app4Evt:
  999. X! #define    kSuspendResumeMessage 1  /* high byte of suspend/resume event message */
  1000. X! #define    SuspResIsResume(evtMessage)    ((evtMessage) & 0x00000001)
  1001. X! 
  1002. X!             switch (theEvent.message >> 24) {
  1003. X!                 case kSuspendResumeMessage:
  1004. X!                 if (!SuspResIsResume(theEvent.message)) {
  1005. X!                     /* ---------- SUSPEND EVENT ------------ */
  1006. X!                     if (macflags & fZoomOnContextSwitch)    
  1007. X!                     SizeWindow(HackWindow,60,60,TRUE);
  1008. X!                 } else {
  1009. X!                     /* ---------- RESUME EVENT ------------- */
  1010. X!                     if (macflags & fZoomOnContextSwitch)    
  1011. X!                     SizeWindow(HackWindow,
  1012. X!                      (t->maxCol * t->charWidth) + 2*Screen_Border,
  1013. X!                      (t->maxRow * t->height) + 2*Screen_Border,
  1014. X!                      TRUE);
  1015. X                  }
  1016. X                  break;
  1017. X!             }
  1018. X!             break;
  1019. X          
  1020. X!             case updateEvt:
  1021. X!             if (HackWindow == (WindowPtr)theEvent.message) {
  1022. X! #ifdef TEXTCOLOR
  1023. X!                 if (t->system.hasColorQD) {
  1024. X!                 Rect    r;
  1025. X!                 GDHandle    gd;
  1026. X!                 
  1027. X!                 r = (**(*(WindowPeek)HackWindow).contRgn).rgnBBox;
  1028. X!                 LocalToGlobal(&r.top);
  1029. X!                 LocalToGlobal(&r.bottom);
  1030. X!                 gd = GetMaxDevice(&r);
  1031. X!                 HLock((Handle)gd);
  1032. X!                 t->inColor = (**(**gd).gdPMap).pixelSize > 1;
  1033. X!                 HUnlock((Handle)gd);
  1034. X!                 }
  1035. X! #endif
  1036. X!                 GetPort(&oldPort);
  1037. X!                 SetPort((GrafPtr)HackWindow);
  1038. X!                 BeginUpdate(HackWindow);
  1039. X!                 t = (term_info *)GetWRefCon(HackWindow);
  1040. X!                 if (t->inColor && macflags & fDoUpdate) {
  1041. X!                 keyCode = flags.toplin;
  1042. X!                 flags.toplin = 0;
  1043. X!                 docrt();
  1044. X!                 flags.toplin = keyCode;
  1045. X!                 } else {
  1046. X!                 for (keyCode = 0;keyCode < t->maxRow; keyCode++) {
  1047. X!                     MoveTo(Screen_Border,
  1048. X!                         t->ascent + (keyCode * t->height)
  1049. X!                             + Screen_Border);
  1050. X!                     DrawText(&t->screen[keyCode][0], 0, t->maxCol);
  1051. X                  }
  1052. X!                 }
  1053. X!                 EndUpdate(HackWindow);
  1054. X!                 SetPort(oldPort);
  1055. X!             } 
  1056. X!             break;
  1057. X                  
  1058. X!             case activateEvt:
  1059. X!             if (HackWindow == (WindowPtr)theEvent.message) {
  1060. X!                 if (theMenu = GetMHandle(editMenu)) {
  1061. X!                 if (theEvent.modifiers & activeFlag) {
  1062. X!                     if (macflags & fDoUpdate) {
  1063. X!                     SetMenuBar(t->fullMBarHandle);
  1064. X!                     for (keyCode = fileMenu;
  1065. X!                           keyCode <= extendMenu;keyCode++) {
  1066. X!                         if (keyCode != editMenu)
  1067. X!                         EnableItem(GetMHandle(keyCode), 0);
  1068. X                      }
  1069. X-                     EnableItem(GetMHandle(appleMenu), 1);
  1070. X-                     }
  1071. X-                     DisableItem(theMenu, 0);
  1072. X-                 } else {
  1073. X-                     EnableItem(theMenu, 0);
  1074. X-                     if (macflags & fDoUpdate) {
  1075. X-                     SetMenuBar(t->shortMBarHandle);
  1076. X-                     for (keyCode = fileMenu;
  1077. X-                           keyCode <= extendMenu;keyCode++) {
  1078. X-                         if (keyCode != editMenu)
  1079. X-                         DisableItem(GetMHandle(keyCode), 0);
  1080. X-                     }
  1081. X-                     DisableItem(GetMHandle(appleMenu), 1);
  1082. X-                     }
  1083. X                  }
  1084. X!                 DrawMenuBar();
  1085. X!                 }
  1086. X!             }
  1087. X!             break;
  1088. X                  
  1089. X!             case mouseDown:
  1090. X!             ch = mButtonDown(theEvent, t, &nextCommand);
  1091. X!             break;
  1092. X!         }
  1093. X!         }        
  1094. X      }
  1095. X      SetPort(oldPort);
  1096. X-     ObscureCursor();
  1097. X      return ((ch == '\r') ? '\n' : ch);
  1098. X  }
  1099. X  
  1100. X  char
  1101. X  mButtonDown(theEvent, t, nextCommand)
  1102. X  EventRecord    theEvent;
  1103. X--- 77,385 ----
  1104. X      }
  1105. X      GetPort(&oldPort);
  1106. X      SetPort(HackWindow);
  1107. X!     if (!(macflags & fDoNonKeyEvt)) {
  1108. X!         cursorPos = -1;
  1109. X!         SetCursor(&ARROW_CURSOR);
  1110. X!     }
  1111. X!     /* do cursor blinking */
  1112. X!     message = TickCount() + cursorTime;
  1113. X!     if (!EventAvail(keyDownMask|mDownMask|autoKeyMask,&theEvent)) {
  1114. X!         keyCode = true;
  1115. X          InvertRect(&cursorRect);
  1116. X!     } else
  1117. X!         keyCode = 0;
  1118. X!     while (!ch) {
  1119. X!         (void)WaitNextEvent(everyEvent, &theEvent, 0L, 0L);
  1120. X!         if (theEvent.what == keyDown || theEvent.what == autoKey) {
  1121. X!             ch = 0;
  1122. X!             ObscureCursor();
  1123. X!             /* use raw key codes */
  1124. X!             temp = keyCode;
  1125. X!             keyCode = (LoWord(theEvent.message) & keyCodeMask)>>8;
  1126. X!              if (keyCode == clearKey) {
  1127. X!                 macflags = macflags ^ fToggleNumPad;
  1128. X!                 SetWTitle(HackWindow,
  1129. X!                     (macflags & fToggleNumPad)    ? "\016NetHack [MOVE]"
  1130. X!                                                 : "\015NetHack [NUM]");
  1131. X!                 keyCode = temp;
  1132. X!                 ch = 0;
  1133. X!                 continue;
  1134. X!             }
  1135. X!             if (temp)
  1136. X!                 InvertRect(&cursorRect);
  1137. X!             if ((macflags & fToggleNumPad) && (keyCode>0x40 &&keyCode < 0x5D) 
  1138. X!                 || (keyCode > 0x7A && keyCode<0x7F)) {
  1139. X!                 ch = t->keyMap[keyCode-65];
  1140. X!                 if ((theEvent.modifiers & shiftKey) && (ch)) {
  1141. X!                     ch = (ch == '.') ? ':' : (char)toupper(ch);
  1142. X!                 }
  1143. X!                 if (ch)
  1144. X!                     break;
  1145. X!             }
  1146. X!             if (keyCode == 50 && noEscapeKey) {
  1147. X!                 ch = (char)ESCAPEkey;    /* ESC */
  1148. X!                 break;
  1149. X!             }            /* make the command key = control key on old Mac keyboards */
  1150. X!             if ((theEvent.modifiers & cmdKey) && noControlKey) {
  1151. X!                 ch = (char)(theEvent.message & 0x1F);
  1152. X!                 break;
  1153. X!             }
  1154. X!             if (theEvent.modifiers & optionKey) {
  1155. X!                 for(start = 43; start < 56; start++) {
  1156. X!                     if (t->keyMap[start] == (char)(theEvent.message & 0xFFL)) {
  1157. X!                         ch = t->keyMap[start - 13];
  1158. X!                         break;
  1159. X!                     }
  1160. X!                 }
  1161. X!             }
  1162. X!             /* not a cursor key or from the numeric keypad */
  1163. X!             if (!ch) {
  1164. X!                 ch = (char)(theEvent.message & 0xFF);
  1165. X!             }
  1166. X!         } else {
  1167. X          /* what other events to handle */
  1168. X!             switch (theEvent.what) {        
  1169. X!             case nullEvent:
  1170. X!                 GetPort(&oldPort1);
  1171. X!                 SetPort((GrafPtr)HackWindow);
  1172. X!                 /* wait until something occurs */
  1173. X!                 if (TickCount() > message) {
  1174. X!                     message = TickCount() + cursorTime;
  1175. X!                     if (!(macflags & fMoveWRTMouse)
  1176. X!                         || (macflags & fMoveWRTMouse && !keyCode)) {
  1177. X!                         InvertRect(&cursorRect);
  1178. X!                         keyCode = !keyCode;
  1179. X!                     }
  1180. X!                 }
  1181. X!                 if (FrontWindow() == HackWindow && (macflags & fDoNonKeyEvt)) {
  1182. X!                     if ((FindWindow(theEvent.where,&theWindow) == inContent)
  1183. X!                         && (macflags & fDoUpdate) && (HackWindow == theWindow)) {
  1184. X!                         
  1185. X!                         GetMouse(&mouseLoc);
  1186. X!                         if (PtInRect(mouseLoc,&box)) {
  1187. X!                             CursHandle theCurs;
  1188. X!                             
  1189. X!                             theCurs = GetCursor(3);
  1190. X!                             cursorPos = 8;
  1191. X!                             SetCursor(*theCurs);
  1192. X!                         } else {
  1193. X!                             PtToAngle(&box,mouseLoc,&temp);
  1194. X!                             if (temp >336 || temp < 23) {
  1195. X!                                 temp = 0;
  1196. X!                             } else {
  1197. X!                                 temp = (temp + 23)/45;
  1198. X!                             }
  1199. X!                             if (temp >=0 && temp <8 && cursorPos != temp) {
  1200. X!                                 SetCursor(*t->cursor[temp]);
  1201. X!                                 cursorPos = temp;
  1202. X! #ifdef THINK_C
  1203. X!                                 repDelay = KeyThresh*2;
  1204. X! #else
  1205. X!                                 repDelay = 42;
  1206. X! #endif
  1207. X!                                 lastMD = theEvent.when;
  1208. X!                             }
  1209. X!                         }
  1210. X!                     } else if (cursorPos>=0) {
  1211. X!                         cursorPos = -1;
  1212. X!                         SetCursor(&ARROW_CURSOR);
  1213. X!                     }
  1214. X                  }
  1215. X+                 if (StillDown() && cursorPos>=0 && cursorPos < 8
  1216. X+                     && TickCount() > lastMD+repDelay) {
  1217. X+                     ch = mButtonDown(theEvent, t, &nextCommand);
  1218. X+                     if (repDelay) {
  1219. X+ #ifdef THINK_C
  1220. X+                         repDelay = KeyRepThresh*2;
  1221. X+ #else
  1222. X+                         repDelay /= 3;
  1223. X+ #endif
  1224. X+                     }
  1225. X+                     lastMD = TickCount();
  1226. X+                     /*return ch;*/
  1227. X+                 }            
  1228. X+                 SetPort(oldPort1);
  1229. X                  break;
  1230. X!             case app4Evt:
  1231. X! #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  1232. X! #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  1233. X! #define    SuspResIsResume(evtMessage)        ((evtMessage) & 0x00000001)
  1234. X! 
  1235. X!                 switch (theEvent.message >> 24) {
  1236. X!                     case kSuspendResumeMessage:
  1237. X!                         if (!SuspResIsResume(theEvent.message)) {
  1238. X!                         /* ---------- SUSPEND EVENT ------------ */
  1239. X!                             if (macflags & fZoomOnContextSwitch
  1240. X!                                 && !EmptyRect(&(**(HackWindow)->visRgn).rgnBBox))
  1241. X!                             {
  1242. X!                                 InvalRect(&HackWindow->portRect);
  1243. X!                                 SizeWindow(HackWindow,60,60,FALSE);
  1244. X!                             }
  1245. X!                         } else {
  1246. X!                         /* ---------- RESUME EVENT ------------- */
  1247. X!                             if (macflags & fZoomOnContextSwitch) {
  1248. X!                                 SizeWindow(HackWindow,
  1249. X!                                  (t->maxCol * t->charWidth) + 2 * Screen_Border,
  1250. X!                                  (t->maxRow * t->height) + 2 * Screen_Border,
  1251. X!                                  TRUE);
  1252. X!                                 SetPort(HackWindow);
  1253. X!                                 InvalRect(&HackWindow->portRect);
  1254. X!                                 if ((int) (theMenu = GetMHandle(editMenu))
  1255. X!                                     && FrontWindow() == HackWindow) {
  1256. X!                                     SetMenuBar(t->fullMBarHandle);
  1257. X!                                     for (temp = fileMenu;temp <= extendMenu;temp++) {
  1258. X!                                     if (temp != editMenu)
  1259. X!                                         EnableItem(GetMHandle(temp), 0);
  1260. X!                                     }
  1261. X!                                     EnableItem(GetMHandle(appleMenu), 1);
  1262. X!                                     DisableItem(theMenu, 0);
  1263. X!                                     DrawMenuBar();
  1264. X!                                 }
  1265. X!                             }
  1266. X!                         }
  1267. X!                         break;
  1268. X!                 }
  1269. X!                 break;
  1270. X          
  1271. X!             case updateEvt:
  1272. X!                 if (HackWindow == (WindowPtr)theEvent.message) {
  1273. X!                     doUpdate(t);
  1274. X                  }
  1275. X!                 break;
  1276. X                  
  1277. X!             case activateEvt:
  1278. X!                 if (HackWindow == (WindowPtr)theEvent.message) {
  1279. X!                     if (theMenu = GetMHandle(editMenu)) {
  1280. X!                         if (theEvent.modifiers & activeFlag) {
  1281. X!                             if (macflags & fDoUpdate) {
  1282. X!                                 SetMenuBar(t->fullMBarHandle);
  1283. X!                                 for (temp = fileMenu;temp <= extendMenu;temp++) {
  1284. X!                                     if (temp != editMenu)
  1285. X!                                         EnableItem(GetMHandle(temp), 0);
  1286. X!                                 }
  1287. X!                                 EnableItem(GetMHandle(appleMenu), 1);
  1288. X!                             }
  1289. X!                             DisableItem(theMenu, 0);
  1290. X!                         } else {
  1291. X!                             EnableItem(theMenu, 0);
  1292. X!                             if (macflags & fDoUpdate) {
  1293. X!                                 SetMenuBar(t->shortMBarHandle);
  1294. X!                                 for (temp = fileMenu;temp <= extendMenu;temp++) {
  1295. X!                                     if (temp != editMenu)
  1296. X!                                         DisableItem(GetMHandle(temp), 0);
  1297. X!                                 }
  1298. X!                                 DisableItem(GetMHandle(appleMenu), 1);
  1299. X!                             }
  1300. X!                         }
  1301. X!                         DrawMenuBar();
  1302. X                      }
  1303. X                  }
  1304. X!                 break;
  1305. X                  
  1306. X!             case mouseDown:
  1307. X!                 ch = mButtonDown(theEvent, t, &nextCommand);
  1308. X!                 break;
  1309. X!             }
  1310. X!         }        
  1311. X      }
  1312. X+     if (keyCode && ch && (theEvent.what != keyDown && theEvent.what != autoKey))
  1313. X+         InvertRect(&cursorRect);
  1314. X+ 
  1315. X      SetPort(oldPort);
  1316. X      return ((ch == '\r') ? '\n' : ch);
  1317. X  }
  1318. X  
  1319. X+ void
  1320. X+ doUpdate(t)
  1321. X+ term_info    *t;
  1322. X+ {
  1323. X+     short    temp;
  1324. X+     GrafPtr    oldPort;
  1325. X+ #ifdef TEXTCOLOR
  1326. X+     if (t->system.hasColorQD) {
  1327. X+         Rect    r;
  1328. X+         GDHandle    gd;
  1329. X+         
  1330. X+         r = (**(*(WindowPeek)HackWindow).contRgn).rgnBBox;
  1331. X+         LocalToGlobal(&r.top);
  1332. X+         LocalToGlobal(&r.bottom);
  1333. X+         gd = GetMaxDevice(&r);
  1334. X+         HLock((Handle)gd);
  1335. X+         t->inColor = (**(**gd).gdPMap).pixelSize > 1;
  1336. X+         HUnlock((Handle)gd);
  1337. X+     }
  1338. X+ #endif
  1339. X+     GetPort(&oldPort);
  1340. X+     SetPort((GrafPtr)HackWindow);
  1341. X+     BeginUpdate(HackWindow);
  1342. X+     if (t->inColor && (macflags & fDoUpdate) && !(macflags & 0x2000)) {
  1343. X+         char    *tmp;
  1344. X+         short    x,y;
  1345. X+         
  1346. X+         tmp = calloc(2*t->maxCol, sizeof(char));
  1347. X+         BlockMove(t->screen[0], tmp, t->maxCol);
  1348. X+         BlockMove(t->screen[1], &tmp[t->maxCol], t->maxCol);
  1349. X+         x = t->tcur_x;
  1350. X+         y = t->tcur_y;
  1351. X+         temp = flags.toplin;
  1352. X+         flags.toplin = 0;
  1353. X+         docrt();
  1354. X+         flags.toplin = temp;
  1355. X+         BlockMove(tmp, t->screen[0], t->maxCol);
  1356. X+         BlockMove(&tmp[t->maxCol], t->screen[1], t->maxCol);
  1357. X+         free(tmp);
  1358. X+         t->tcur_y = y;
  1359. X+         t->tcur_x = x;
  1360. X+     }
  1361. X+     if (macflags & fDoUpdate) {
  1362. X+         for (temp = 0;
  1363. X+             temp < ((t->inColor && !(macflags & fFullScrKluge))
  1364. X+                 ? 2 : t->maxRow);
  1365. X+             temp++) {
  1366. X+             if ((macflags & fScreenKluges) == fScreenKluges
  1367. X+                 && temp == t->maxRow-1){
  1368. X+                 if(flags.standout)
  1369. X+                     standoutbeg();
  1370. X+             }
  1371. X+             MoveTo(Screen_Border,
  1372. X+                 t->ascent + (temp * t->height) + Screen_Border);
  1373. X+             DrawText(&t->screen[temp][0], 0, t->maxCol);
  1374. X+             if ((macflags & fScreenKluges) == fScreenKluges
  1375. X+                 && temp == t->maxRow-1){
  1376. X+                 if(flags.standout)
  1377. X+                     standoutend();
  1378. X+             }
  1379. X+         }
  1380. X+ 
  1381. X+         if (macflags & fDisplayKluge) {
  1382. X+             register struct line *tl;
  1383. X+             int curline, lth;
  1384. X+             
  1385. X+             if(flags.toplin == 1) more();    /* ab@unido */
  1386. X+             remember_topl();
  1387. X+         
  1388. X+             lth = CO - macmaxlen - 2;           /* Use full screen width */
  1389. X+             if (maclinect < LI && lth >= 10) {             /* in a corner */
  1390. X+                 home ();
  1391. X+                 cl_end ();
  1392. X+                 flags.toplin = 0;
  1393. X+                 curline = 1;
  1394. X+                 for (tl = mactexthead; tl; tl = tl->next_line) {
  1395. X+                     curs (lth, curline);
  1396. X+                     if(curline > 1)
  1397. X+                         cl_end ();
  1398. X+                     xputs(tl->line_text);
  1399. X+                     curx = curx + strlen(tl->line_text);
  1400. X+                     curline++;
  1401. X+                 }
  1402. X+                 curs (lth, curline);
  1403. X+             }
  1404. X+         }
  1405. X+     }
  1406. X+     EndUpdate(HackWindow);
  1407. X+     SetPort(oldPort);
  1408. X+ }
  1409. X+ 
  1410. X  char
  1411. X  mButtonDown(theEvent, t, nextCommand)
  1412. X  EventRecord    theEvent;
  1413. X***************
  1414. X*** 236,243 ****
  1415. X      GrafPtr    oldPort;
  1416. X  
  1417. X      ch = '\0';
  1418. X!     if (macflags & fDoNonKeyEvt) 
  1419. X!     switch (FindWindow(theEvent.where,&theWindow)) {
  1420. X          case inMenuBar:
  1421. X  
  1422. X          SetCursor(&ARROW_CURSOR);
  1423. X--- 396,403 ----
  1424. X      GrafPtr    oldPort;
  1425. X  
  1426. X      ch = '\0';
  1427. X!     if (macflags & fDoNonKeyEvt) {
  1428. X!         switch (FindWindow(theEvent.where,&theWindow)) {
  1429. X          case inMenuBar:
  1430. X  
  1431. X          SetCursor(&ARROW_CURSOR);
  1432. X***************
  1433. X*** 251,257 ****
  1434. X              (void)SystemEdit((short)message - 1);
  1435. X              break;
  1436. X              case appleMenu:
  1437. X!             if (LoWord(message) > 2) {
  1438. X                  GetItem(GetMHandle(HiWord(message)),LoWord(message),
  1439. X                      deskacc);
  1440. X                  SetMenuBar(t->shortMBarHandle);
  1441. X--- 411,417 ----
  1442. X              (void)SystemEdit((short)message - 1);
  1443. X              break;
  1444. X              case appleMenu:
  1445. X!             if (LoWord(message) > 1) {
  1446. X                  GetItem(GetMHandle(HiWord(message)),LoWord(message),
  1447. X                      deskacc);
  1448. X                  SetMenuBar(t->shortMBarHandle);
  1449. X***************
  1450. X*** 324,339 ****
  1451. X          }
  1452. X          menuBar = (ROM85 == -1) ? 20 : GetMBarHeight();
  1453. X  
  1454. X!         SetRect(&boundsRect, Screen_Border, menuBar + Screen_Border,
  1455. X!             SCREEN_BITS.bounds.right - Screen_Border,
  1456. X!             SCREEN_BITS.bounds.bottom - Screen_Border);
  1457. X          SetCursor(&ARROW_CURSOR);
  1458. X          DragWindow(theWindow, theEvent.where, &boundsRect);
  1459. X          break;
  1460. X      
  1461. X!         case inContent:
  1462. X!         SelectWindow(theWindow);
  1463. X          break;
  1464. X      }
  1465. X      return ch;
  1466. X  }
  1467. X--- 484,557 ----
  1468. X          }
  1469. X          menuBar = (ROM85 == -1) ? 20 : GetMBarHeight();
  1470. X  
  1471. X!         {
  1472. X!         RgnHandle fooRgn = GetGrayRgn();
  1473. X!             boundsRect = (*fooRgn)->rgnBBox;
  1474. X!         }
  1475. X          SetCursor(&ARROW_CURSOR);
  1476. X          DragWindow(theWindow, theEvent.where, &boundsRect);
  1477. X          break;
  1478. X      
  1479. X!     case inContent:
  1480. X!         if (theWindow != FrontWindow()) {
  1481. X!             SelectWindow(theWindow);
  1482. X!         } else if (theWindow == HackWindow) {
  1483. X!             Point    mouseLoc;
  1484. X!             Rect    box;
  1485. X!             short    temp;
  1486. X! 
  1487. X!             if(flags.wantspace) {
  1488. X!                 ch = 0x20;
  1489. X!             } else {
  1490. X!                 box.left = (u.ux-1) * t->charWidth + Screen_Border + (t->charWidth/2);
  1491. X!                 box.right = box.left + 1;
  1492. X!                 box.top = (u.uy+1) * t->height + Screen_Border + t->height/2;
  1493. X!                 box.bottom = box.top + 1;
  1494. X!                 GetMouse(&mouseLoc);
  1495. X!                 PtToAngle(&box,mouseLoc,&temp);
  1496. X!                 if (temp >337 || temp < 23) {
  1497. X!                     temp = 0;
  1498. X!                 } else {
  1499. X!                     temp = (temp + 23)/45;
  1500. X!                 }
  1501. X!                 switch(cursorPos) {
  1502. X!                     case 0:
  1503. X!                         ch = 'k';
  1504. X!                         break;
  1505. X!                     case 1:
  1506. X!                         ch = 'u';
  1507. X!                         break;
  1508. X!                     case 2:
  1509. X!                         ch = 'l';
  1510. X!                         break;
  1511. X!                     case 3:
  1512. X!                         ch = 'n';
  1513. X!                         break;
  1514. X!                     case 4:
  1515. X!                         ch = 'j';
  1516. X!                         break;
  1517. X!                     case 5:
  1518. X!                         ch = 'b';
  1519. X!                         break;
  1520. X!                     case 6:
  1521. X!                         ch = 'h';
  1522. X!                         break;
  1523. X!                     case 7:
  1524. X!                         ch ='y';
  1525. X!                         break;
  1526. X!                     case 8:
  1527. X!                         ch = '.';
  1528. X!                         break;
  1529. X!                 }
  1530. X!                 if ((theEvent.modifiers & shiftKey) && (ch)) {
  1531. X!                     ch = (ch == '.') ? ':' : (char)toupper(ch);
  1532. X!                 }
  1533. X!             }
  1534. X!         }            
  1535. X          break;
  1536. X+         }
  1537. X+     } else {
  1538. X+         if(flags.wantspace) ch = 0x20;
  1539. X      }
  1540. X      return ch;
  1541. X  }
  1542. X***************
  1543. X*** 381,387 ****
  1544. X  {    
  1545. X      EventRecord    theEvent;
  1546. X      
  1547. X!     return (EventAvail(keyDownMask, &theEvent));
  1548. X  }
  1549. X  #endif
  1550. X  
  1551. X--- 599,606 ----
  1552. X  {    
  1553. X      EventRecord    theEvent;
  1554. X      
  1555. X!     SystemTask();
  1556. X!     return (EventAvail(keyDownMask | mDownMask, &theEvent));
  1557. X  }
  1558. X  #endif
  1559. X  
  1560. X***************
  1561. X*** 410,415 ****
  1562. X--- 629,672 ----
  1563. X      return 1;
  1564. X  }
  1565. X  
  1566. X+ static void
  1567. X+ checkScroll(t)
  1568. X+ term_info *t;
  1569. X+ {
  1570. X+     if (t->tcur_y >= t->maxRow-1) {
  1571. X+         short    temp;
  1572. X+         char    *s;
  1573. X+ 
  1574. X+         BlockMove((Ptr)t->screen[1], (Ptr)t->screen[0],
  1575. X+             (Size)((t->maxRow - 1) * t->maxCol));
  1576. X+         for (temp = 0, s = t->screen[t->maxRow - 1];
  1577. X+                 temp < t->maxCol; temp++, s++) {
  1578. X+             *s = ' ';
  1579. X+         }
  1580. X+         {
  1581. X+             Pattern p, o;
  1582. X+             Rect    window;
  1583. X+             
  1584. X+             if (macflags & fInvertedScreen) {
  1585. X+                 BlockMove((Ptr)&((GrafPtr)HackWindow)->bkPat, (Ptr)&o,
  1586. X+                         sizeof(Pattern));
  1587. X+                 GetIndPattern(&p, sysPatListID,1);
  1588. X+                 BackPat(p);
  1589. X+             }
  1590. X+             window = HackWindow->portRect;
  1591. X+             InsetRect(&window, 4,4);
  1592. X+             window.top += t->height;
  1593. X+             ScrollRect(&window, 0, -t->height,
  1594. X+                     ((WindowPeek)HackWindow)->updateRgn);
  1595. X+             ValidRect(&window);
  1596. X+             if (macflags & fInvertedScreen) {
  1597. X+                 BackPat(o);
  1598. X+             }
  1599. X+         }
  1600. X+         t->tcur_y = t->maxRow - 1;
  1601. X+     }
  1602. X+ }
  1603. X+ 
  1604. X  void
  1605. X  mput(s)
  1606. X  char    *s;
  1607. X***************
  1608. X*** 532,538 ****
  1609. X          
  1610. X          if (sLen) {
  1611. X          while (stmp < (s + sLen)) {
  1612. X!             temp = (x + charleft - 1 < t->maxCol) ? charleft : t->maxCol - x;
  1613. X              savech = '\0';
  1614. X              c1 = stmp + temp;    /* point to the char after the end */
  1615. X              c = index(stmp, '\n');
  1616. X--- 789,795 ----
  1617. X          
  1618. X          if (sLen) {
  1619. X          while (stmp < (s + sLen)) {
  1620. X!             temp = (x + charleft - 1 < t->maxCol - 1) ? charleft : t->maxCol - x;
  1621. X              savech = '\0';
  1622. X              c1 = stmp + temp;    /* point to the char after the end */
  1623. X              c = index(stmp, '\n');
  1624. X***************
  1625. X*** 556,577 ****
  1626. X              if (!savech) {
  1627. X                  t->tcur_x += temp;
  1628. X              }
  1629. X!             if (t->tcur_x == t->maxCol || savech) {
  1630. X!             t->tcur_x = 0;
  1631. X!             if (savech != '\r')
  1632. X!                 y = (++t->tcur_y);
  1633. X!                 /* should probably check for overflow */
  1634. X!             }
  1635. X!             x = t->tcur_x;
  1636. X!             cur.h = Screen_Border;
  1637. X!             cur.v = y * t->height + t->ascent + Screen_Border;
  1638. X!             MoveTo(cur.h,cur.v);
  1639. X!         }
  1640. X          }
  1641. X      }
  1642. X!     if (t->tcur_x >= t->maxCol) {
  1643. X          t->tcur_x = t->tcur_x % t->maxCol;
  1644. X          t->tcur_y++;
  1645. X      }
  1646. X      SetPort(prevPort);
  1647. X  }
  1648. X--- 813,840 ----
  1649. X              if (!savech) {
  1650. X                  t->tcur_x += temp;
  1651. X              }
  1652. X! 
  1653. X!             if (t->tcur_x >= t->maxCol-1 || savech) {
  1654. X!                 if (savech != '\r') {
  1655. X!                     if (t->tcur_y >= t->maxRow-1) {
  1656. X!                         checkScroll(t);
  1657. X!                     } else {
  1658. X!                         y = (++t->tcur_y);
  1659. X!                     }
  1660. X!                 }
  1661. X!     
  1662. X!                 x = t->tcur_x = 0;
  1663. X!                 cur.h = Screen_Border;
  1664. X!                 cur.v = y * t->height + t->ascent + Screen_Border;
  1665. X!                 MoveTo(cur.h,cur.v);
  1666. X!             }
  1667. X          }
  1668. X      }
  1669. X!     }
  1670. X!     if (t->tcur_x >= t->maxCol-1) {
  1671. X          t->tcur_x = t->tcur_x % t->maxCol;
  1672. X          t->tcur_y++;
  1673. X+         checkScroll(t);
  1674. X      }
  1675. X      SetPort(prevPort);
  1676. X  }
  1677. X***************
  1678. X*** 621,641 ****
  1679. X      }
  1680. X      if (c == '\007') {
  1681. X          SysBeep(1);
  1682. X!     } else if ((c != '\n') && (c != '\r')) {
  1683. X          t->screen[y][x] = c;
  1684. X          DrawText(&c, 0, 1);
  1685. X!         if (!savech)
  1686. X              t->tcur_x++;
  1687. X!     } else {
  1688. X!         t->tcur_x = 0;
  1689. X!         if (t->tcur_y < t->maxRow) {
  1690. X!             if (c == '\n')
  1691. X                  t->tcur_y++;
  1692. X          }
  1693. X-         cur.h = (t->tcur_x * t->charWidth) + Screen_Border;
  1694. X-         cur.v = t->ascent + (t->tcur_y * t->height) + Screen_Border;
  1695. X-         MoveTo(cur.h,cur.v);
  1696. X      }
  1697. X      SetPort(prevPort);    
  1698. X      return 1;
  1699. X  }
  1700. X--- 884,917 ----
  1701. X      }
  1702. X      if (c == '\007') {
  1703. X          SysBeep(1);
  1704. X!     } else if ((c == '\n') || (c == '\r')) {
  1705. X!         t->tcur_x = 0;
  1706. X!         if (t->tcur_y >= t->maxRow && c == '\r') {
  1707. X!             t->tcur_y = t->maxRow - 1;
  1708. X!         } else if (c == '\n') {
  1709. X!             if (t->tcur_y >= t->maxRow-1) {
  1710. X!                 checkScroll(t);
  1711. X!             } else {
  1712. X!                 t->tcur_y++;
  1713. X!             }
  1714. X!         }
  1715. X!     } else {
  1716. X          t->screen[y][x] = c;
  1717. X          DrawText(&c, 0, 1);
  1718. X!         if (!savech) {
  1719. X              t->tcur_x++;
  1720. X!             if (t->tcur_x >= t->maxCol)
  1721. X!             {
  1722. X!                 t->tcur_x = 0;
  1723. X                  t->tcur_y++;
  1724. X+                 checkScroll(t);
  1725. X+             }
  1726. X          }
  1727. X      }
  1728. X+     cur.h = (t->tcur_x * t->charWidth) + Screen_Border;
  1729. X+     cur.v = t->ascent + (t->tcur_y * t->height) + Screen_Border;
  1730. X+     MoveTo(cur.h,cur.v);
  1731. X+ 
  1732. X      SetPort(prevPort);    
  1733. X      return 1;
  1734. X  }
  1735. X***************
  1736. X*** 742,747 ****
  1737. X--- 1018,1053 ----
  1738. X      return 1;
  1739. X  }
  1740. X  
  1741. X+ DialogTHndl
  1742. X+ centreDlgBox(resNum, clip)
  1743. X+ short    resNum;
  1744. X+ Boolean    clip;
  1745. X+ {
  1746. X+     DialogTHndl    th = (DialogTHndl) GetResource('DLOG', resNum);
  1747. X+     Rect    rect;
  1748. X+     short    dv, dh;
  1749. X+ 
  1750. X+     /* centre dialog box on screen */
  1751. X+     if (th) {
  1752. X+         rect = SCREEN_BITS.bounds;
  1753. X+         HLock((Handle)th);
  1754. X+         dv = ((**th).boundsRect.bottom - (**th).boundsRect.top)/2;
  1755. X+         dv -= (clip) ? 20 : 0;
  1756. X+         dh = ((**th).boundsRect.right - (**th).boundsRect.left)/2;
  1757. X+     
  1758. X+         (**th).boundsRect.bottom =
  1759. X+                 (rect.bottom + rect.top + MBarHeight)/2 + dv;
  1760. X+         (**th).boundsRect.top     =
  1761. X+                 (rect.bottom + rect.top + MBarHeight)/2 - dv;
  1762. X+         (**th).boundsRect.right     = (rect.right + rect.left)/2 + dh;
  1763. X+         (**th).boundsRect.left     = (rect.right + rect.left)/2 - dh;
  1764. X+         HUnlock((Handle)th);
  1765. X+     } else
  1766. X+         panic("Couldn't load dialog resource");    
  1767. X+ 
  1768. X+     return th;
  1769. X+ }
  1770. X+ 
  1771. X  short
  1772. X  aboutBox(prompt)
  1773. X  short    prompt;
  1774. X***************
  1775. X*** 757,777 ****
  1776. X      GrafPtr    oldPort;
  1777. X      EventRecord    theEvent;
  1778. X      term_info    *t;
  1779. X!     DialogTHndl    th = (DialogTHndl) GetResource('DLOG', 129);
  1780. X!     short    dv, dh;
  1781. X  
  1782. X      /* if about box on startup, centre about box on screen */
  1783. X      if (!prompt) {
  1784. X!         rect = SCREEN_BITS.bounds;
  1785. X!         dv = ((**th).boundsRect.bottom - 40 - (**th).boundsRect.top)/2;
  1786. X!         dh = ((**th).boundsRect.right - (**th).boundsRect.left)/2;
  1787. X! 
  1788. X!         (**th).boundsRect.bottom =
  1789. X!                 (rect.bottom + rect.top + MBarHeight)/2 + dv;
  1790. X!         (**th).boundsRect.top     =
  1791. X!                 (rect.bottom + rect.top + MBarHeight)/2 - dv;
  1792. X!         (**th).boundsRect.right     = (rect.right + rect.left)/2 + dh;
  1793. X!         (**th).boundsRect.left     = (rect.right + rect.left)/2 - dh;
  1794. X      }
  1795. X  
  1796. X      GetPort(&oldPort);
  1797. X--- 1063,1073 ----
  1798. X      GrafPtr    oldPort;
  1799. X      EventRecord    theEvent;
  1800. X      term_info    *t;
  1801. X!     DialogTHndl    th;
  1802. X  
  1803. X      /* if about box on startup, centre about box on screen */
  1804. X      if (!prompt) {
  1805. X!         th = centreDlgBox(129, TRUE);
  1806. X      }
  1807. X  
  1808. X      GetPort(&oldPort);
  1809. X***************
  1810. X*** 800,805 ****
  1811. X--- 1096,1102 ----
  1812. X          }
  1813. X      } else {
  1814. X          while (!itemHit) {
  1815. X+             SystemTask();
  1816. X              if (GetNextEvent(everyEvent,&theEvent))
  1817. X                  if (theEvent.what == mouseDown ||
  1818. X                            theEvent.what == keyDown ||
  1819. X***************
  1820. X*** 807,813 ****
  1821. X                      itemHit = OK_BUTTON;
  1822. X          }
  1823. X      }
  1824. X!     CloseDialog(theDialog);
  1825. X      ReleaseResource((Handle)th);
  1826. X      SetPort(oldPort);
  1827. X      return (itemHit == MORE_INFO_BUTTON);
  1828. X--- 1104,1110 ----
  1829. X                      itemHit = OK_BUTTON;
  1830. X          }
  1831. X      }
  1832. X!     DisposDialog(theDialog);
  1833. X      ReleaseResource((Handle)th);
  1834. X      SetPort(oldPort);
  1835. X      return (itemHit == MORE_INFO_BUTTON);
  1836. X*** mac/Old/macfile.c    Mon Feb 19 21:23:03 1990
  1837. X--- mac/macfile.c    Thu Feb  8 17:45:37 1990
  1838. X***************
  1839. X*** 4,13 ****
  1840. X  
  1841. X  /*    Common routines to locate files using mac dialog boxes */
  1842. X  
  1843. X- /*#define MAKEDEFS_C    1    /* define when using makedefs */
  1844. X  #include "config.h"
  1845. X  #ifdef MACOS
  1846. X  
  1847. X  short
  1848. X  findNamedFile(filename,type,reply)
  1849. X  char    *filename;
  1850. X--- 4,13 ----
  1851. X  
  1852. X  /*    Common routines to locate files using mac dialog boxes */
  1853. X  
  1854. X  #include "config.h"
  1855. X  #ifdef MACOS
  1856. X  
  1857. X+ #define    LARGE_SFGETDLG    -4000
  1858. X  short
  1859. X  findNamedFile(filename,type,reply)
  1860. X  char    *filename;
  1861. X***************
  1862. X*** 24,30 ****
  1863. X      
  1864. X      name[0] = (char)strlen(filename);
  1865. X      Strcpy((char *)&name[1], filename);
  1866. X!     dialog = GetNewDialog(128,&storage,(WindowPtr)-1);
  1867. X      
  1868. X      if (type == 1)
  1869. X          ParamText("\005 save","\004 for",name,"");
  1870. X--- 24,30 ----
  1871. X      
  1872. X      name[0] = (char)strlen(filename);
  1873. X      Strcpy((char *)&name[1], filename);
  1874. X!     SetResLoad(TRUE);
  1875. X      
  1876. X      if (type == 1)
  1877. X          ParamText("\005 save","\004 for",name,"");
  1878. X***************
  1879. X*** 50,60 ****
  1880. X      }
  1881. X      reply->good = TRUE;
  1882. X      do {
  1883. X!         BringToFront((WindowPtr)dialog);
  1884. X!         ShowWindow((WindowPtr)dialog);
  1885. X!         DrawDialog(dialog);
  1886. X!         SFGetFile(where,prompt,0L,numTypes,types,0L,reply);
  1887. X!         HideWindow((WindowPtr)dialog);
  1888. X          if (reply->good) {
  1889. X              if ((type == 2 && 
  1890. X                  !strncmp((char *)&name[1],
  1891. X--- 50,56 ----
  1892. X      }
  1893. X      reply->good = TRUE;
  1894. X      do {
  1895. X!         SFPGetFile(where,prompt,0L,numTypes,types,0L,reply,LARGE_SFGETDLG,0L);
  1896. X          if (reply->good) {
  1897. X              if ((type == 2 && 
  1898. X                  !strncmp((char *)&name[1],
  1899. X***************
  1900. X*** 65,77 ****
  1901. X              }
  1902. X          }
  1903. X      } while (!ok && reply->good);
  1904. X!     CloseDialog(dialog);
  1905. X      return ok;
  1906. X  }
  1907. X  
  1908. X! #ifndef MAKEDEFS_C
  1909. X  extern WindowPtr HackWindow;
  1910. X! 
  1911. X  /*    this function also gets called by topten() in topten.c to
  1912. X   *    locate the record file, but it doesn't matter at this point
  1913. X   *    since the game is over by now. If nethack ever restarts,
  1914. X--- 61,73 ----
  1915. X              }
  1916. X          }
  1917. X      } while (!ok && reply->good);
  1918. X! 
  1919. X      return ok;
  1920. X  }
  1921. X  
  1922. X! #ifdef CUSTOM_IO
  1923. X  extern WindowPtr HackWindow;
  1924. X! extern short macflags;
  1925. X  /*    this function also gets called by topten() in topten.c to
  1926. X   *    locate the record file, but it doesn't matter at this point
  1927. X   *    since the game is over by now. If nethack ever restarts,
  1928. X***************
  1929. X*** 83,109 ****
  1930. X  char    *fileName, *rdmode;
  1931. X  {
  1932. X      term_info *t;
  1933. X-     SFReply    reply;
  1934. X      FILE    *fp;
  1935. X          
  1936. X      t = (term_info *)GetWRefCon(HackWindow);
  1937. X-     if (t->auxFileVRefNum) {
  1938. X-         SetVol(0L,t->auxFileVRefNum);
  1939. X-     } else
  1940. X-         SetVol(0L, t->recordVRefNum);
  1941. X  
  1942. X!     reply.good = false;
  1943. X      fp = fopen(fileName, rdmode);
  1944. X!     if (!fp && findNamedFile(fileName,2,&reply)) {
  1945. X!         if (reply.good) {
  1946. X!             t->auxFileVRefNum = reply.vRefNum;
  1947. X          }
  1948. X!     }
  1949. X!     if (!fp)
  1950. X          fp = fopen(fileName, rdmode);
  1951. X!     else if (!t->auxFileVRefNum && reply.good) {
  1952. X!         (void)GetVol((StringPtr)&reply.fName,&t->auxFileVRefNum);
  1953. X      }
  1954. X      return fp;
  1955. X  }
  1956. X  #endif
  1957. X--- 79,117 ----
  1958. X  char    *fileName, *rdmode;
  1959. X  {
  1960. X      term_info *t;
  1961. X      FILE    *fp;
  1962. X          
  1963. X      t = (term_info *)GetWRefCon(HackWindow);
  1964. X  
  1965. X!     SetVol(0L, t->recordVRefNum);
  1966. X      fp = fopen(fileName, rdmode);
  1967. X!     if (!fp) {        
  1968. X!         SFReply    reply;
  1969. X! 
  1970. X!         if (t->auxFileVRefNum) {
  1971. X!             SetVol(0L,t->auxFileVRefNum);
  1972. X          }
  1973. X!         
  1974. X!         reply.good = false;
  1975. X          fp = fopen(fileName, rdmode);
  1976. X!         if (!fp && findNamedFile(fileName,2,&reply)) {
  1977. X!             if (reply.good) {
  1978. X!                 t->auxFileVRefNum = reply.vRefNum;
  1979. X!             }
  1980. X!         }
  1981. X!         
  1982. X!         if (!fp)
  1983. X!             fp = fopen(fileName, rdmode);
  1984. X!         else if (!t->auxFileVRefNum && reply.good) {
  1985. X!             (void)GetVol((StringPtr)&reply.fName,&t->auxFileVRefNum);
  1986. X!         }
  1987. X! 
  1988. X!         SetPort(HackWindow);
  1989. X!         if ((macflags & fDoUpdate) && !reply.good)
  1990. X!             docrt();
  1991. X! 
  1992. X      }
  1993. X+ 
  1994. X      return fp;
  1995. X  }
  1996. X  #endif
  1997. X*** mac/Old/macinit.c    Mon Feb 19 21:23:16 1990
  1998. X--- mac/macinit.c    Fri Feb 16 19:04:35 1990
  1999. X***************
  2000. X*** 7,20 ****
  2001. X  #include    "hack.h"
  2002. X  
  2003. X  #ifdef MACOS
  2004. X  
  2005. X  /* Global variables */
  2006. X  extern WindowPtr    HackWindow;    /* points to NetHack's window */
  2007. X  char    *keys[8];
  2008. X  short macflags;
  2009. X  typedef struct defaultData {
  2010. X      long    defaultFlags;
  2011. X!     long    fontSize;
  2012. X      Str255    fontName;
  2013. X  } defaultData;
  2014. X  #define    fDFZoomWindow    0x02L
  2015. X--- 7,28 ----
  2016. X  #include    "hack.h"
  2017. X  
  2018. X  #ifdef MACOS
  2019. X+ # ifdef THINK_C
  2020. X+ #include    <MemoryMgr.h>
  2021. X+ # else
  2022. X+ #include    <Memory.h>
  2023. X+ #define ApplLimit 0x130         /* application limit [pointer]*/
  2024. X+ # endif
  2025. X  
  2026. X  /* Global variables */
  2027. X  extern WindowPtr    HackWindow;    /* points to NetHack's window */
  2028. X  char    *keys[8];
  2029. X  short macflags;
  2030. X+ Boolean    lowMem;
  2031. X+ long    lowMemLimit;
  2032. X  typedef struct defaultData {
  2033. X      long    defaultFlags;
  2034. X!     long    lowMemLimit;
  2035. X      Str255    fontName;
  2036. X  } defaultData;
  2037. X  #define    fDFZoomWindow    0x02L
  2038. X***************
  2039. X*** 39,49 ****
  2040. X--- 47,71 ----
  2041. X      term_info    *t;
  2042. X      
  2043. X      /* standard Mac initialization */
  2044. X+ #ifdef THINK_C
  2045. X+     SetApplLimit((Ptr)ApplLimit - 8192);    /* an extra 8K for stack */
  2046. X+ #else
  2047. X+     SetApplLimit(*(long *)ApplLimit - 8192);
  2048. X+ #endif    
  2049. X      MaxApplZone();
  2050. X+     UnloadSeg(mprintf);
  2051. X+     for (i = 2; i<9; i++) {
  2052. X+         temp = GetResource('CODE', i);
  2053. X+         HUnlock(temp);
  2054. X+         MoveHHi(temp);
  2055. X+         HLock(temp);
  2056. X+     }
  2057. X+     
  2058. X      MoreMasters();
  2059. X      MoreMasters();
  2060. X      MoreMasters();
  2061. X      MoreMasters();
  2062. X+     lowMem = (FreeMem() < 700 *1024) ? TRUE : FALSE;
  2063. X      InitGraf(&MAINGRAFPORT);
  2064. X      
  2065. X      InitFonts();
  2066. X***************
  2067. X*** 56,62 ****
  2068. X      
  2069. X      /* Application-specific startup code */
  2070. X      theMenu = NewMenu(appleMenu, "\001\024");    /*  apple menu  */
  2071. X!     AppendMenu(theMenu,"\030About NetHack 3.0g\311;(-");
  2072. X      AddResMenu(theMenu, 'DRVR');
  2073. X      InsertMenu(theMenu, 0);
  2074. X      DisableItem(theMenu,0);
  2075. X--- 78,89 ----
  2076. X      
  2077. X      /* Application-specific startup code */
  2078. X      theMenu = NewMenu(appleMenu, "\001\024");    /*  apple menu  */
  2079. X!     {
  2080. X!         char    tmp[256];
  2081. X!         sprintf(&tmp[1],"About NetHack %s\311;(-", VERSION);
  2082. X!         tmp[0] = (char)strlen(&tmp[1]);
  2083. X!         AppendMenu(theMenu,tmp);
  2084. X!     }
  2085. X      AddResMenu(theMenu, 'DRVR');
  2086. X      InsertMenu(theMenu, 0);
  2087. X      DisableItem(theMenu,0);
  2088. X***************
  2089. X*** 93,99 ****
  2090. X      macflags = (fToggleNumPad | fDoNonKeyEvt);
  2091. X      
  2092. X      /* Set font to monaco, user-defined font or to Hackfont if available */
  2093. X!     size = 9;
  2094. X      strcpy((char *)&font[0], "\006Monaco");
  2095. X      
  2096. X      temp = GetResource(HACK_DATA, DEFAULT_DATA);
  2097. X--- 120,130 ----
  2098. X      macflags = (fToggleNumPad | fDoNonKeyEvt);
  2099. X      
  2100. X      /* Set font to monaco, user-defined font or to Hackfont if available */
  2101. X!     if ((SCREEN_BITS.bounds.bottom - SCREEN_BITS.bounds.top) >400
  2102. X!         && (SCREEN_BITS.bounds.right - SCREEN_BITS.bounds.left) > 580)
  2103. X!         size = 12;
  2104. X!     else
  2105. X!         size = 9;
  2106. X      strcpy((char *)&font[0], "\006Monaco");
  2107. X      
  2108. X      temp = GetResource(HACK_DATA, DEFAULT_DATA);
  2109. X***************
  2110. X*** 100,106 ****
  2111. X      if (temp) {
  2112. X          HLock(temp);
  2113. X          dD = (defaultData *)(*temp);
  2114. X!         size = (short)dD->fontSize;
  2115. X          strncpy((char *)&font[0], (char *)&dD->fontName[0],
  2116. X                      (short)dD->fontName[0] + 1);
  2117. X          if (dD->defaultFlags & fDFZoomWindow)
  2118. X--- 131,137 ----
  2119. X      if (temp) {
  2120. X          HLock(temp);
  2121. X          dD = (defaultData *)(*temp);
  2122. X!         lowMemLimit = dD->lowMemLimit;
  2123. X          strncpy((char *)&font[0], (char *)&dD->fontName[0],
  2124. X                      (short)dD->fontName[0] + 1);
  2125. X          if (dD->defaultFlags & fDFZoomWindow)
  2126. X***************
  2127. X*** 171,176 ****
  2128. X--- 202,212 ----
  2129. X          SysBeep(1);
  2130. X      }
  2131. X  
  2132. X+     /* Some tweaking to allow for intl. ADB keyboard (unknown) */
  2133. X+     if (t->system.machineType > envMacPlus && !t->system.keyBoardType) {
  2134. X+         t->system.keyBoardType = envStandADBKbd;
  2135. X+     }
  2136. X+ 
  2137. X  #define    KEY_MAP    103
  2138. X      temp = GetResource(HACK_DATA, KEY_MAP);
  2139. X      if (temp) {
  2140. X***************
  2141. X*** 198,207 ****
  2142. X  
  2143. X      /* give time for Multifinder to bring NetHack window to front */
  2144. X      for(tempFont = 0; tempFont<10; tempFont++) {
  2145. X!         (void)GetNextEvent(everyEvent,&theEvent);
  2146. X      }
  2147. X  
  2148. X!     HackWindow = NewWindow(0L, &boundsRect, "\015NetHack [MOV]",
  2149. X              TRUE, noGrowDocProc, (WindowPtr)-1, FALSE, (long)t);
  2150. X  
  2151. X      t->inColor = 0;
  2152. X--- 234,244 ----
  2153. X  
  2154. X      /* give time for Multifinder to bring NetHack window to front */
  2155. X      for(tempFont = 0; tempFont<10; tempFont++) {
  2156. X!         SystemTask();
  2157. X!         (void)GetNextEvent(nullEvent,&theEvent);
  2158. X      }
  2159. X  
  2160. X!     HackWindow = NewWindow(0L, &boundsRect, "\016NetHack [MOVE]",
  2161. X              TRUE, noGrowDocProc, (WindowPtr)-1, FALSE, (long)t);
  2162. X  
  2163. X      t->inColor = 0;
  2164. X***************
  2165. X*** 253,258 ****
  2166. X--- 290,299 ----
  2167. X          panic("Can't get OBJECT resource data.");
  2168. X      }
  2169. X      
  2170. X+     for (i = 0; i<8; i++) {
  2171. X+         t->cursor[i] = GetCursor(100+i);
  2172. X+     }
  2173. X+     
  2174. X      (void)aboutBox(0);    
  2175. X      return 0;
  2176. X  }
  2177. X***************
  2178. X*** 325,328 ****
  2179. X--- 366,460 ----
  2180. X      free((char *)level.monsters);
  2181. X  }
  2182. X  #endif /* SMALLDATA */
  2183. X+ 
  2184. X+ #define    OPTIONS            "Nethack prefs"
  2185. X+ 
  2186. X+ # ifdef AZTEC
  2187. X+ #undef OMASK
  2188. X+ #define OMASK    O_RDONLY
  2189. X+ # else
  2190. X+ #undef OMASK
  2191. X+ #define OMASK    (O_RDONLY | O_BINARY )
  2192. X+ # endif
  2193. X+ 
  2194. X+ int
  2195. X+ read_config_file()
  2196. X+ {
  2197. X+ 
  2198. X+     int optfd;
  2199. X+     optfd = 0;
  2200. X+     if ( (optfd = open(OPTIONS, OMASK)) > (int)NULL){
  2201. X+         read_opts(optfd);
  2202. X+         (void) close(optfd);
  2203. X+     }
  2204. X+ }
  2205. X+ 
  2206. X+ int
  2207. X+ write_opts()
  2208. X+ {
  2209. X+     int fd;
  2210. X+     short temp_flags;
  2211. X+ 
  2212. X+     if((fd = open(OPTIONS, O_WRONLY | O_BINARY)) <= 0) {
  2213. X+         OSErr    result;
  2214. X+         char    *tmp;
  2215. X+         
  2216. X+         tmp = CtoPstr(OPTIONS);
  2217. X+         result = Create((StringPtr)tmp, (short)0, CREATOR, AUXIL_TYPE);
  2218. X+          if (result == noErr)
  2219. X+              fd = open(OPTIONS, O_WRONLY | O_BINARY);
  2220. X+      }
  2221. X+ 
  2222. X+     if (fd < 0)
  2223. X+         pline("can't create options file!");
  2224. X+     else {
  2225. X+         write(fd, &flags, sizeof(flags));
  2226. X+     
  2227. X+         write(fd, plname, PL_NSIZ);
  2228. X+     
  2229. X+         write(fd, dogname, 63);
  2230. X+     
  2231. X+         write(fd, catname, 63);
  2232. X+         
  2233. X+         temp_flags = (macflags & fZoomOnContextSwitch) ? 1 : 0;
  2234. X+         write(fd, &temp_flags, sizeof(short));
  2235. X+     
  2236. X+ #ifdef TUTTI_FRUTTI
  2237. X+         write(fd, pl_fruit, PL_FSIZ);
  2238. X+ #endif
  2239. X+         write(fd, inv_order, strlen(inv_order)+1);
  2240. X+         close(fd);
  2241. X+     }
  2242. X+     return 0;
  2243. X+ }
  2244. X+ 
  2245. X+ int
  2246. X+ read_opts(fd)
  2247. X+ int fd;
  2248. X+ {    char tmp_order[20];
  2249. X+     short    temp_flags;
  2250. X+     
  2251. X+     read(fd, (char *)&flags, sizeof(flags));
  2252. X+ 
  2253. X+     read(fd, plname, PL_NSIZ);
  2254. X+ 
  2255. X+     read(fd, dogname, 63);
  2256. X+     
  2257. X+     read(fd, catname, 63);
  2258. X+     
  2259. X+     read(fd, &temp_flags, sizeof(short));
  2260. X+     if (temp_flags & 0x01)
  2261. X+         macflags |= fZoomOnContextSwitch;
  2262. X+     else
  2263. X+         macflags &= ~fZoomOnContextSwitch;
  2264. X+ 
  2265. X+ #ifdef TUTTI_FRUTTI
  2266. X+     read(fd, pl_fruit, PL_FSIZ);
  2267. X+ #endif
  2268. X+     read(fd,tmp_order,strlen(inv_order)+1);
  2269. X+     if(strlen(tmp_order) == strlen(inv_order))
  2270. X+         strcpy(inv_order,tmp_order);
  2271. X+     return 0;
  2272. X+ }
  2273. X+ 
  2274. X  #endif /* MACOS */
  2275. X
  2276. END_OF_FILE
  2277. if test 56738 -ne `wc -c <'patch7.15'`; then
  2278.     echo shar: \"'patch7.15'\" unpacked with wrong size!
  2279. fi
  2280. # end of 'patch7.15'
  2281. echo shar: End of archive 5 \(of 30\).
  2282. cp /dev/null ark5isdone
  2283. MISSING=""
  2284. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ; do
  2285.     if test ! -f ark${I}isdone ; then
  2286.     MISSING="${MISSING} ${I}"
  2287.     fi
  2288. done
  2289. if test "${MISSING}" = "" ; then
  2290.     echo You have unpacked all 30 archives.
  2291.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2292. else
  2293.     echo You still need to unpack the following archives:
  2294.     echo "        " ${MISSING}
  2295. fi
  2296. ##  End of shell archive.
  2297. exit 0
  2298.